@@ -106,7 +106,8 @@ private IDictionary<string, Tuple<string, ContentDispositionHeaderValue>> Downlo
106
106
{ PackageUrl , Tuple . Create < string , ContentDispositionHeaderValue > ( PackageUrlContent , null ) } ,
107
107
{ NoDispositionUrl , Tuple . Create < string , ContentDispositionHeaderValue > ( Content , null ) } ,
108
108
{ NoExtensionUrl , Tuple . Create ( Content , noExtension ) } ,
109
- { NoSegmentUrl , Tuple . Create ( Content , justAttachments ) }
109
+ { NoSegmentUrl , Tuple . Create ( Content , justAttachments ) } ,
110
+ { BrokenUrl , null }
110
111
} ;
111
112
}
112
113
@@ -139,10 +140,14 @@ public void Dispose()
139
140
public Task < IHttpResponseMessageWrapper > GetResponseAsync ( string url )
140
141
{
141
142
var result = _results [ url ] ;
142
- byte [ ] byteArray = Encoding . ASCII . GetBytes ( result . Item1 ) ;
143
- var stream = new MemoryStream ( byteArray ) ;
143
+ MemoryStream stream = null ;
144
+ if ( result != null )
145
+ {
146
+ byte [ ] byteArray = Encoding . ASCII . GetBytes ( result . Item1 ) ;
147
+ stream = new MemoryStream ( byteArray ) ;
148
+ }
144
149
145
- return Task . FromResult < IHttpResponseMessageWrapper > ( new TestHttpResponseMessageWrapper ( stream , result . Item2 ) ) ;
150
+ return Task . FromResult < IHttpResponseMessageWrapper > ( new TestHttpResponseMessageWrapper ( stream , result ? . Item2 ) ) ;
146
151
}
147
152
}
148
153
@@ -154,7 +159,17 @@ public class TestHttpResponseMessageWrapper : IHttpResponseMessageWrapper
154
159
155
160
public bool IsSuccessCode ( )
156
161
{
157
- return true ;
162
+ switch ( StatusCode )
163
+ {
164
+ case HttpStatusCode . OK :
165
+ case HttpStatusCode . Created :
166
+ case HttpStatusCode . NoContent :
167
+ case HttpStatusCode . Accepted :
168
+ return true ;
169
+ case HttpStatusCode . NotFound :
170
+ default :
171
+ return false ;
172
+ }
158
173
}
159
174
160
175
private readonly ContentDispositionHeaderValue _contentDisposition ;
@@ -164,6 +179,10 @@ public TestHttpResponseMessageWrapper(
164
179
ContentDispositionHeaderValue header )
165
180
{
166
181
Stream = Task . FromResult < Stream > ( stream ) ;
182
+ if ( header is null && stream is null )
183
+ {
184
+ StatusCode = HttpStatusCode . NotFound ;
185
+ }
167
186
_contentDisposition = header ;
168
187
}
169
188
0 commit comments