@@ -28,7 +28,7 @@ void OnParseCommands(ImageCommandContext context)
2828 complete = true ;
2929 }
3030
31- using ( TestServer server = ImageSharpTestServer . CreateWithActions ( OnParseCommands ) )
31+ using ( TestServer server = ImageSharpTestServer . CreateWithActionsNoCache ( OnParseCommands ) )
3232 {
3333 await server . CreateClient ( ) . GetAsync ( url + Command ) ;
3434 }
@@ -37,6 +37,34 @@ void OnParseCommands(ImageCommandContext context)
3737 }
3838
3939 [ Theory ]
40+ [ InlineData ( ImageSharpTestServer . PhysicalTestImage ) ]
41+ [ InlineData ( ImageSharpTestServer . AzureTestImage ) ]
42+ public async Task ShouldRunOnValidateActionWithCacheAsync ( string url )
43+ {
44+ bool complete = false ;
45+ void OnParseCommands ( ImageCommandContext context )
46+ {
47+ Assert . NotNull ( context ) ;
48+ Assert . NotNull ( context . Context ) ;
49+ Assert . NotNull ( context . Commands ) ;
50+ Assert . NotNull ( context . Parser ) ;
51+ complete = true ;
52+ }
53+
54+ using ( TestServer server = ImageSharpTestServer . CreateWithActionsCache ( OnParseCommands ) )
55+ {
56+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
57+ Assert . True ( complete ) ;
58+
59+ complete = false ;
60+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
61+ }
62+
63+ Assert . True ( complete ) ;
64+ }
65+
66+ [ Theory ]
67+ [ InlineData ( ImageSharpTestServer . PhysicalTestImage ) ]
4068 [ InlineData ( ImageSharpTestServer . AzureTestImage ) ]
4169 public async Task ShouldRunOnValidateActionNoCommandsAsync ( string url )
4270 {
@@ -50,16 +78,45 @@ void OnParseCommands(ImageCommandContext context)
5078 complete = true ;
5179 }
5280
53- using ( TestServer server = ImageSharpTestServer . CreateWithActions ( OnParseCommands ) )
81+ using ( TestServer server = ImageSharpTestServer . CreateWithActionsNoCache ( OnParseCommands ) )
5482 {
5583 await server . CreateClient ( ) . GetAsync ( url ) ;
5684 }
5785
5886 Assert . True ( complete ) ;
5987 }
6088
61- [ Fact ]
62- public async Task ShouldRunOnBeforeSaveActionAsync ( )
89+ [ Theory ]
90+ [ InlineData ( ImageSharpTestServer . PhysicalTestImage ) ]
91+ [ InlineData ( ImageSharpTestServer . AzureTestImage ) ]
92+ public async Task ShouldRunOnValidateActionNoCommandsWithCacheAsync ( string url )
93+ {
94+ bool complete = false ;
95+ void OnParseCommands ( ImageCommandContext context )
96+ {
97+ Assert . NotNull ( context ) ;
98+ Assert . NotNull ( context . Context ) ;
99+ Assert . NotNull ( context . Commands ) ;
100+ Assert . NotNull ( context . Parser ) ;
101+ complete = true ;
102+ }
103+
104+ using ( TestServer server = ImageSharpTestServer . CreateWithActionsCache ( OnParseCommands ) )
105+ {
106+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
107+ Assert . True ( complete ) ;
108+
109+ complete = false ;
110+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
111+ }
112+
113+ Assert . True ( complete ) ;
114+ }
115+
116+ [ Theory ]
117+ [ InlineData ( ImageSharpTestServer . PhysicalTestImage ) ]
118+ [ InlineData ( ImageSharpTestServer . AzureTestImage ) ]
119+ public async Task ShouldRunOnBeforeSaveActionAsync ( string url )
63120 {
64121 bool complete = false ;
65122 void OnBeforeSave ( FormattedImage image )
@@ -70,16 +127,41 @@ void OnBeforeSave(FormattedImage image)
70127 complete = true ;
71128 }
72129
73- using ( TestServer server = ImageSharpTestServer . CreateWithActions ( null , OnBeforeSave ) )
130+ using ( TestServer server = ImageSharpTestServer . CreateWithActionsNoCache ( null , OnBeforeSave ) )
74131 {
75- await server . CreateClient ( ) . GetAsync ( ImageSharpTestServer . PhysicalTestImage + Command ) ;
132+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
76133 }
77134
78135 Assert . True ( complete ) ;
79136 }
80137
81- [ Fact ]
82- public async Task ShouldRunOnProcessedActionAsync ( )
138+ [ Theory ]
139+ [ InlineData ( ImageSharpTestServer . PhysicalTestImage ) ]
140+ [ InlineData ( ImageSharpTestServer . AzureTestImage ) ]
141+ public async Task ShouldNotRunOnBeforeSaveActionWithCacheAsync ( string url )
142+ {
143+ bool complete = false ;
144+ void OnBeforeSave ( FormattedImage image )
145+ {
146+ complete = true ;
147+ }
148+
149+ using ( TestServer server = ImageSharpTestServer . CreateWithActionsCache ( null , OnBeforeSave ) )
150+ {
151+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
152+
153+ Assert . False ( complete ) ;
154+
155+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
156+ }
157+
158+ Assert . False ( complete ) ;
159+ }
160+
161+ [ Theory ]
162+ [ InlineData ( ImageSharpTestServer . PhysicalTestImage ) ]
163+ [ InlineData ( ImageSharpTestServer . AzureTestImage ) ]
164+ public async Task ShouldRunOnProcessedActionAsync ( string url )
83165 {
84166 bool complete = false ;
85167 void OnProcessed ( ImageProcessingContext context )
@@ -91,16 +173,61 @@ void OnProcessed(ImageProcessingContext context)
91173 complete = true ;
92174 }
93175
94- using ( TestServer server = ImageSharpTestServer . CreateWithActions ( null , null , OnProcessed ) )
176+ using ( TestServer server = ImageSharpTestServer . CreateWithActionsNoCache ( null , null , OnProcessed ) )
177+ {
178+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
179+ }
180+
181+ Assert . True ( complete ) ;
182+ }
183+
184+ [ Theory ]
185+ [ InlineData ( ImageSharpTestServer . PhysicalTestImage ) ]
186+ [ InlineData ( ImageSharpTestServer . AzureTestImage ) ]
187+ public async Task ShouldNotRunOnProcessedActionWithCacheAsync ( string url )
188+ {
189+ bool complete = false ;
190+ void OnProcessed ( ImageProcessingContext context )
191+ {
192+ complete = true ;
193+ }
194+
195+ using ( TestServer server = ImageSharpTestServer . CreateWithActionsCache ( null , null , OnProcessed ) )
95196 {
96- await server . CreateClient ( ) . GetAsync ( ImageSharpTestServer . PhysicalTestImage + Command ) ;
197+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
198+ Assert . False ( complete ) ;
199+
200+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
201+ }
202+
203+ Assert . False ( complete ) ;
204+ }
205+
206+ [ Theory ]
207+ [ InlineData ( ImageSharpTestServer . PhysicalTestImage ) ]
208+ [ InlineData ( ImageSharpTestServer . AzureTestImage ) ]
209+ public async Task ShouldRunOnPrepareResponseActionAsync ( string url )
210+ {
211+ bool complete = false ;
212+ void OnPrepareResponse ( HttpContext context )
213+ {
214+ Assert . NotNull ( context ) ;
215+ Assert . NotNull ( context . Response ) ;
216+ complete = true ;
217+ }
218+
219+ using ( TestServer server = ImageSharpTestServer . CreateWithActionsNoCache ( null , null , null , OnPrepareResponse ) )
220+ {
221+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
97222 }
98223
99224 Assert . True ( complete ) ;
100225 }
101226
102- [ Fact ]
103- public async Task ShouldRunOnPrepareResponseActionAsync ( )
227+ [ Theory ]
228+ [ InlineData ( ImageSharpTestServer . PhysicalTestImage ) ]
229+ [ InlineData ( ImageSharpTestServer . AzureTestImage ) ]
230+ public async Task ShouldRunOnPrepareResponseActionWithCacheAsync ( string url )
104231 {
105232 bool complete = false ;
106233 void OnPrepareResponse ( HttpContext context )
@@ -110,9 +237,13 @@ void OnPrepareResponse(HttpContext context)
110237 complete = true ;
111238 }
112239
113- using ( TestServer server = ImageSharpTestServer . CreateWithActions ( null , null , null , OnPrepareResponse ) )
240+ using ( TestServer server = ImageSharpTestServer . CreateWithActionsCache ( null , null , null , OnPrepareResponse ) )
114241 {
115- await server . CreateClient ( ) . GetAsync ( ImageSharpTestServer . PhysicalTestImage + Command ) ;
242+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
243+ Assert . True ( complete ) ;
244+
245+ complete = false ;
246+ await server . CreateClient ( ) . GetAsync ( url + Command ) ;
116247 }
117248
118249 Assert . True ( complete ) ;
0 commit comments