@@ -20,7 +20,7 @@ public class CaptchaImageMiddlewareTests
2020 private Mock < ISession > _mockSession ;
2121 private Mock < IHeaderDictionary > _mockHeaders ;
2222 private MemoryStream _responseBodyStream ;
23- private CaptchaImageMiddleware _middleware ;
23+ private SessionCaptchaImageMiddleware _middleware ;
2424
2525 [ SetUp ]
2626 public void SetUp ( )
@@ -44,10 +44,10 @@ public void SetUp()
4444 _mockResponse . Setup ( x => x . Headers ) . Returns ( _mockHeaders . Object ) ;
4545 _mockResponse . Setup ( x => x . Body ) . Returns ( _responseBodyStream ) ;
4646
47- _middleware = new CaptchaImageMiddleware ( _mockNext . Object ) ;
47+ _middleware = new SessionCaptchaImageMiddleware ( _mockNext . Object ) ;
4848
4949 // Reset options to default state before each test
50- CaptchaImageMiddleware . Options = new CaptchaImageMiddlewareOptions
50+ SessionCaptchaImageMiddleware . Options = new SessionCaptchaImageMiddlewareOptions
5151 {
5252 RequestPath = "/captcha-image" ,
5353 ImageWidth = 100 ,
@@ -105,7 +105,7 @@ public async Task Invoke_WhenPathDoesNotMatch_CallsNextMiddleware()
105105 public async Task Invoke_WithCustomRequestPath_WorksCorrectly ( )
106106 {
107107 // Arrange
108- CaptchaImageMiddleware . Options . RequestPath = "/custom-captcha" ;
108+ SessionCaptchaImageMiddleware . Options . RequestPath = "/custom-captcha" ;
109109 var testImageBytes = new byte [ ] { 0x89 , 0x50 , 0x4E , 0x47 } ;
110110 _mockRequest . Setup ( x => x . Path ) . Returns ( "/custom-captcha" ) ;
111111 _mockCaptcha . Setup ( x => x . GenerateCaptchaImageBytes ( _mockSession . Object , 100 , 36 , null ) )
@@ -127,8 +127,8 @@ public async Task Invoke_WithCustomRequestPath_WorksCorrectly()
127127 public async Task Invoke_WithCustomImageSize_UsesCorrectDimensions ( )
128128 {
129129 // Arrange
130- CaptchaImageMiddleware . Options . ImageWidth = 200 ;
131- CaptchaImageMiddleware . Options . ImageHeight = 80 ;
130+ SessionCaptchaImageMiddleware . Options . ImageWidth = 200 ;
131+ SessionCaptchaImageMiddleware . Options . ImageHeight = 80 ;
132132 var testImageBytes = new byte [ ] { 0x89 , 0x50 , 0x4E , 0x47 } ;
133133 _mockRequest . Setup ( x => x . Path ) . Returns ( "/captcha-image" ) ;
134134 _mockCaptcha . Setup ( x => x . GenerateCaptchaImageBytes ( _mockSession . Object , 200 , 80 , null ) )
@@ -145,8 +145,8 @@ public async Task Invoke_WithCustomImageSize_UsesCorrectDimensions()
145145 public async Task Invoke_WithWidthExceeding640_LimitsTo640 ( )
146146 {
147147 // Arrange
148- CaptchaImageMiddleware . Options . ImageWidth = 800 ;
149- CaptchaImageMiddleware . Options . ImageHeight = 100 ;
148+ SessionCaptchaImageMiddleware . Options . ImageWidth = 800 ;
149+ SessionCaptchaImageMiddleware . Options . ImageHeight = 100 ;
150150 var testImageBytes = new byte [ ] { 0x89 , 0x50 , 0x4E , 0x47 } ;
151151 _mockRequest . Setup ( x => x . Path ) . Returns ( "/captcha-image" ) ;
152152 _mockCaptcha . Setup ( x => x . GenerateCaptchaImageBytes ( _mockSession . Object , 640 , 100 , null ) )
@@ -163,8 +163,8 @@ public async Task Invoke_WithWidthExceeding640_LimitsTo640()
163163 public async Task Invoke_WithHeightExceeding480_LimitsTo480 ( )
164164 {
165165 // Arrange
166- CaptchaImageMiddleware . Options . ImageWidth = 200 ;
167- CaptchaImageMiddleware . Options . ImageHeight = 600 ;
166+ SessionCaptchaImageMiddleware . Options . ImageWidth = 200 ;
167+ SessionCaptchaImageMiddleware . Options . ImageHeight = 600 ;
168168 var testImageBytes = new byte [ ] { 0x89 , 0x50 , 0x4E , 0x47 } ;
169169 _mockRequest . Setup ( x => x . Path ) . Returns ( "/captcha-image" ) ;
170170 _mockCaptcha . Setup ( x => x . GenerateCaptchaImageBytes ( _mockSession . Object , 200 , 480 , null ) )
@@ -181,8 +181,8 @@ public async Task Invoke_WithHeightExceeding480_LimitsTo480()
181181 public async Task Invoke_WithBothDimensionsExceedingLimits_LimitsBoth ( )
182182 {
183183 // Arrange
184- CaptchaImageMiddleware . Options . ImageWidth = 1000 ;
185- CaptchaImageMiddleware . Options . ImageHeight = 600 ;
184+ SessionCaptchaImageMiddleware . Options . ImageWidth = 1000 ;
185+ SessionCaptchaImageMiddleware . Options . ImageHeight = 600 ;
186186 var testImageBytes = new byte [ ] { 0x89 , 0x50 , 0x4E , 0x47 } ;
187187 _mockRequest . Setup ( x => x . Path ) . Returns ( "/captcha-image" ) ;
188188 _mockCaptcha . Setup ( x => x . GenerateCaptchaImageBytes ( _mockSession . Object , 640 , 480 , null ) )
@@ -199,8 +199,8 @@ public async Task Invoke_WithBothDimensionsExceedingLimits_LimitsBoth()
199199 public async Task Invoke_WithExactlyMaxDimensions_DoesNotLimit ( )
200200 {
201201 // Arrange
202- CaptchaImageMiddleware . Options . ImageWidth = 640 ;
203- CaptchaImageMiddleware . Options . ImageHeight = 480 ;
202+ SessionCaptchaImageMiddleware . Options . ImageWidth = 640 ;
203+ SessionCaptchaImageMiddleware . Options . ImageHeight = 480 ;
204204 var testImageBytes = new byte [ ] { 0x89 , 0x50 , 0x4E , 0x47 } ;
205205 _mockRequest . Setup ( x => x . Path ) . Returns ( "/captcha-image" ) ;
206206 _mockCaptcha . Setup ( x => x . GenerateCaptchaImageBytes ( _mockSession . Object , 640 , 480 , null ) )
@@ -221,7 +221,7 @@ public async Task Invoke_WithExactlyMaxDimensions_DoesNotLimit()
221221 public async Task Invoke_WithDisableCacheTrue_SetsCacheControlHeaders ( )
222222 {
223223 // Arrange
224- CaptchaImageMiddleware . Options . DisableCache = true ;
224+ SessionCaptchaImageMiddleware . Options . DisableCache = true ;
225225 var testImageBytes = new byte [ ] { 0x89 , 0x50 , 0x4E , 0x47 } ;
226226 _mockRequest . Setup ( x => x . Path ) . Returns ( "/captcha-image" ) ;
227227 _mockCaptcha . Setup ( x => x . GenerateCaptchaImageBytes ( _mockSession . Object , 100 , 36 , null ) )
@@ -238,7 +238,7 @@ public async Task Invoke_WithDisableCacheTrue_SetsCacheControlHeaders()
238238 public async Task Invoke_WithDisableCacheFalse_DoesNotSetCacheControlHeaders ( )
239239 {
240240 // Arrange
241- CaptchaImageMiddleware . Options . DisableCache = false ;
241+ SessionCaptchaImageMiddleware . Options . DisableCache = false ;
242242 var testImageBytes = new byte [ ] { 0x89 , 0x50 , 0x4E , 0x47 } ;
243243 _mockRequest . Setup ( x => x . Path ) . Returns ( "/captcha-image" ) ;
244244 _mockCaptcha . Setup ( x => x . GenerateCaptchaImageBytes ( _mockSession . Object , 100 , 36 , null ) )
@@ -472,7 +472,7 @@ public async Task Invoke_WithDifferentSessionObjects_CallsCaptchaWithCorrectSess
472472 public void Options_DefaultValues_AreSetCorrectly ( )
473473 {
474474 // Arrange & Act
475- var options = new CaptchaImageMiddlewareOptions ( ) ;
475+ var options = new SessionCaptchaImageMiddlewareOptions ( ) ;
476476
477477 // Assert
478478 Assert . That ( options . DisableCache , Is . True ) ;
@@ -485,12 +485,12 @@ public void Options_DefaultValues_AreSetCorrectly()
485485 public void Options_StaticProperty_CanBeModified ( )
486486 {
487487 // Arrange
488- var originalOptions = CaptchaImageMiddleware . Options ;
488+ var originalOptions = SessionCaptchaImageMiddleware . Options ;
489489
490490 try
491491 {
492492 // Act
493- CaptchaImageMiddleware . Options = new CaptchaImageMiddlewareOptions
493+ SessionCaptchaImageMiddleware . Options = new SessionCaptchaImageMiddlewareOptions
494494 {
495495 RequestPath = "/test-captcha" ,
496496 ImageWidth = 150 ,
@@ -499,15 +499,15 @@ public void Options_StaticProperty_CanBeModified()
499499 } ;
500500
501501 // Assert
502- Assert . That ( CaptchaImageMiddleware . Options . RequestPath . Value , Is . EqualTo ( "/test-captcha" ) ) ;
503- Assert . That ( CaptchaImageMiddleware . Options . ImageWidth , Is . EqualTo ( 150 ) ) ;
504- Assert . That ( CaptchaImageMiddleware . Options . ImageHeight , Is . EqualTo ( 75 ) ) ;
505- Assert . That ( CaptchaImageMiddleware . Options . DisableCache , Is . False ) ;
502+ Assert . That ( SessionCaptchaImageMiddleware . Options . RequestPath . Value , Is . EqualTo ( "/test-captcha" ) ) ;
503+ Assert . That ( SessionCaptchaImageMiddleware . Options . ImageWidth , Is . EqualTo ( 150 ) ) ;
504+ Assert . That ( SessionCaptchaImageMiddleware . Options . ImageHeight , Is . EqualTo ( 75 ) ) ;
505+ Assert . That ( SessionCaptchaImageMiddleware . Options . DisableCache , Is . False ) ;
506506 }
507507 finally
508508 {
509509 // Cleanup
510- CaptchaImageMiddleware . Options = originalOptions ;
510+ SessionCaptchaImageMiddleware . Options = originalOptions ;
511511 }
512512 }
513513
0 commit comments