File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -290,7 +290,7 @@ public void ShouldThrowCustomException()
290290 public void ShouldThrowExceptionWhenRequestIsNull ( )
291291 {
292292 //Arrange
293- var requester = new FakeHttpRequester ( "" ) ;
293+ var requester = new FakeHttpRequester ( "DownloadFile.txt " ) ;
294294
295295 //Act
296296 var exception = Assert . ThrowsException < ArgumentNullException > ( ( ) =>
@@ -301,5 +301,31 @@ public void ShouldThrowExceptionWhenRequestIsNull()
301301 //Assert
302302 Assert . AreEqual ( "request" , exception . ParamName ) ;
303303 }
304+
305+ [ TestMethod ]
306+ public void ShouldThrowExceptionWhenConfigSourceIsNull ( )
307+ {
308+ //Act
309+ var exception = Assert . ThrowsException < ArgumentNullException > ( ( ) =>
310+ {
311+ new FakeHttpRequester ( null ) ;
312+ } ) ;
313+
314+ //Assert
315+ Assert . AreEqual ( "configSource" , exception . ParamName ) ;
316+ }
317+
318+ [ TestMethod ]
319+ public void ShouldThrowExceptionWhenFileNotExists ( )
320+ {
321+ //Act
322+ var exception = Assert . ThrowsException < FileLoadException > ( ( ) =>
323+ {
324+ new FakeHttpRequester ( "FakePath" ) ;
325+ } ) ;
326+
327+ //Assert
328+ Assert . AreEqual ( "File FakePath nor exists" , exception . Message ) ;
329+ }
304330 }
305331}
Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ public class FakeHttpRequester: IHttpRequester
2121 public FakeHttpRequester ( string configSource )
2222 {
2323 _configSource = configSource ?? throw new ArgumentNullException ( nameof ( configSource ) ) ;
24+ if ( ! File . Exists ( configSource ) )
25+ {
26+ throw new FileLoadException ( $ "File { configSource } nor exists") ;
27+ }
2428 }
2529
2630 /// <summary>
You can’t perform that action at this time.
0 commit comments