6
6
using System . Threading . Tasks ;
7
7
using Microsoft . AspNet . Builder ;
8
8
using Microsoft . AspNet . TestHost ;
9
- using Shouldly ;
10
9
using Xunit ;
11
10
12
11
namespace Microsoft . AspNet . StaticFiles
@@ -19,8 +18,8 @@ public async Task ServerShouldReturnETag()
19
18
TestServer server = TestServer . Create ( app => app . UseFileServer ( ) ) ;
20
19
21
20
HttpResponseMessage response = await server . CreateClient ( ) . GetAsync ( "http://localhost/SubFolder/Extra.xml" ) ;
22
- response . Headers . ETag . ShouldNotBe ( null ) ;
23
- response . Headers . ETag . Tag . ShouldNotBe ( null ) ;
21
+ Assert . NotNull ( response . Headers . ETag ) ;
22
+ Assert . NotNull ( response . Headers . ETag . Tag ) ;
24
23
}
25
24
26
25
[ Fact ]
@@ -30,7 +29,7 @@ public async Task SameETagShouldBeReturnedAgain()
30
29
31
30
HttpResponseMessage response1 = await server . CreateClient ( ) . GetAsync ( "http://localhost/SubFolder/Extra.xml" ) ;
32
31
HttpResponseMessage response2 = await server . CreateClient ( ) . GetAsync ( "http://localhost/SubFolder/Extra.xml" ) ;
33
- response1 . Headers . ETag . ShouldBe ( response2 . Headers . ETag ) ;
32
+ Assert . Equal ( response2 . Headers . ETag , response1 . Headers . ETag ) ;
34
33
}
35
34
36
35
// 14.24 If-Match
@@ -48,7 +47,7 @@ public async Task IfMatchShouldReturn412WhenNotListed()
48
47
var req = new HttpRequestMessage ( HttpMethod . Get , "http://localhost/SubFolder/Extra.xml" ) ;
49
48
req . Headers . Add ( "If-Match" , "\" fake\" " ) ;
50
49
HttpResponseMessage resp = await server . CreateClient ( ) . SendAsync ( req ) ;
51
- resp . StatusCode . ShouldBe ( HttpStatusCode . PreconditionFailed ) ;
50
+ Assert . Equal ( HttpStatusCode . PreconditionFailed , resp . StatusCode ) ;
52
51
}
53
52
54
53
[ Fact ]
@@ -60,7 +59,7 @@ public async Task IfMatchShouldBeServedWhenListed()
60
59
var req = new HttpRequestMessage ( HttpMethod . Get , "http://localhost/SubFolder/Extra.xml" ) ;
61
60
req . Headers . Add ( "If-Match" , original . Headers . ETag . ToString ( ) ) ;
62
61
HttpResponseMessage resp = await server . CreateClient ( ) . SendAsync ( req ) ;
63
- resp . StatusCode . ShouldBe ( HttpStatusCode . OK ) ;
62
+ Assert . Equal ( HttpStatusCode . OK , resp . StatusCode ) ;
64
63
}
65
64
66
65
[ Fact ]
@@ -70,7 +69,7 @@ public async Task IfMatchShouldBeServedForAstrisk()
70
69
var req = new HttpRequestMessage ( HttpMethod . Get , "http://localhost/SubFolder/Extra.xml" ) ;
71
70
req . Headers . Add ( "If-Match" , "*" ) ;
72
71
HttpResponseMessage resp = await server . CreateClient ( ) . SendAsync ( req ) ;
73
- resp . StatusCode . ShouldBe ( HttpStatusCode . OK ) ;
72
+ Assert . Equal ( HttpStatusCode . OK , resp . StatusCode ) ;
74
73
}
75
74
76
75
// 14.26 If-None-Match
@@ -96,12 +95,12 @@ public async Task IfNoneMatchShouldReturn304ForMatchingOnGetAndHeadMethod()
96
95
var req2 = new HttpRequestMessage ( HttpMethod . Get , "http://localhost/SubFolder/Extra.xml" ) ;
97
96
req2 . Headers . Add ( "If-None-Match" , resp1 . Headers . ETag . ToString ( ) ) ;
98
97
HttpResponseMessage resp2 = await server . CreateClient ( ) . SendAsync ( req2 ) ;
99
- resp2 . StatusCode . ShouldBe ( HttpStatusCode . NotModified ) ;
98
+ Assert . Equal ( HttpStatusCode . NotModified , resp2 . StatusCode ) ;
100
99
101
100
var req3 = new HttpRequestMessage ( HttpMethod . Head , "http://localhost/SubFolder/Extra.xml" ) ;
102
101
req3 . Headers . Add ( "If-None-Match" , resp1 . Headers . ETag . ToString ( ) ) ;
103
102
HttpResponseMessage resp3 = await server . CreateClient ( ) . SendAsync ( req3 ) ;
104
- resp3 . StatusCode . ShouldBe ( HttpStatusCode . NotModified ) ;
103
+ Assert . Equal ( HttpStatusCode . NotModified , resp3 . StatusCode ) ;
105
104
}
106
105
107
106
[ Fact ]
@@ -113,12 +112,12 @@ public async Task IfNoneMatchShouldBeIgnoredForNonTwoHundredAnd304Responses()
113
112
var req2 = new HttpRequestMessage ( HttpMethod . Post , "http://localhost/SubFolder/Extra.xml" ) ;
114
113
req2 . Headers . Add ( "If-None-Match" , resp1 . Headers . ETag . ToString ( ) ) ;
115
114
HttpResponseMessage resp2 = await server . CreateClient ( ) . SendAsync ( req2 ) ;
116
- resp2 . StatusCode . ShouldBe ( HttpStatusCode . NotFound ) ;
115
+ Assert . Equal ( HttpStatusCode . NotFound , resp2 . StatusCode ) ;
117
116
118
117
var req3 = new HttpRequestMessage ( HttpMethod . Put , "http://localhost/SubFolder/Extra.xml" ) ;
119
118
req3 . Headers . Add ( "If-None-Match" , resp1 . Headers . ETag . ToString ( ) ) ;
120
119
HttpResponseMessage resp3 = await server . CreateClient ( ) . SendAsync ( req3 ) ;
121
- resp3 . StatusCode . ShouldBe ( HttpStatusCode . NotFound ) ;
120
+ Assert . Equal ( HttpStatusCode . NotFound , resp3 . StatusCode ) ;
122
121
}
123
122
124
123
// 14.26 If-None-Match
@@ -137,7 +136,7 @@ public async Task ServerShouldReturnLastModified()
137
136
TestServer server = TestServer . Create ( app => app . UseFileServer ( ) ) ;
138
137
139
138
HttpResponseMessage response = await server . CreateClient ( ) . GetAsync ( "http://localhost/SubFolder/Extra.xml" ) ;
140
- response . Content . Headers . LastModified . ShouldNotBe ( null ) ;
139
+ Assert . NotNull ( response . Content . Headers . LastModified ) ;
141
140
}
142
141
143
142
// 13.3.4
@@ -163,7 +162,7 @@ public async Task MatchingBothConditionsReturnsNotModified()
163
162
. And ( req => req . Headers . IfModifiedSince = resp1 . Content . Headers . LastModified )
164
163
. GetAsync ( ) ;
165
164
166
- resp2 . StatusCode . ShouldBe ( HttpStatusCode . NotModified ) ;
165
+ Assert . Equal ( HttpStatusCode . NotModified , resp2 . StatusCode ) ;
167
166
}
168
167
169
168
[ Fact ]
@@ -196,9 +195,9 @@ public async Task MissingEitherOrBothConditionsReturnsNormally()
196
195
. And ( req => req . Headers . IfModifiedSince = furtureDate )
197
196
. GetAsync ( ) ;
198
197
199
- resp2 . StatusCode . ShouldBe ( HttpStatusCode . OK ) ;
200
- resp3 . StatusCode . ShouldBe ( HttpStatusCode . OK ) ;
201
- resp4 . StatusCode . ShouldBe ( HttpStatusCode . OK ) ;
198
+ Assert . Equal ( HttpStatusCode . OK , resp2 . StatusCode ) ;
199
+ Assert . Equal ( HttpStatusCode . OK , resp3 . StatusCode ) ;
200
+ Assert . Equal ( HttpStatusCode . OK , resp4 . StatusCode ) ;
202
201
}
203
202
204
203
// 14.25 If-Modified-Since
@@ -223,7 +222,7 @@ public async Task InvalidIfModifiedSinceDateFormatGivesNormalGet()
223
222
. AddHeader ( "If-Modified-Since" , "bad-date" )
224
223
. GetAsync ( ) ;
225
224
226
- res . StatusCode . ShouldBe ( HttpStatusCode . OK ) ;
225
+ Assert . Equal ( HttpStatusCode . OK , res . StatusCode ) ;
227
226
}
228
227
229
228
// b) If the variant has been modified since the If-Modified-Since
@@ -247,7 +246,7 @@ public async Task IfModifiedSinceDateEqualsLastModifiedShouldReturn304()
247
246
. And ( req => req . Headers . IfModifiedSince = res1 . Content . Headers . LastModified )
248
247
. GetAsync ( ) ;
249
248
250
- res2 . StatusCode . ShouldBe ( HttpStatusCode . NotModified ) ;
249
+ Assert . Equal ( HttpStatusCode . NotModified , res2 . StatusCode ) ;
251
250
}
252
251
}
253
252
}
0 commit comments