public void ShouldReturnErrorIfIPassNullFileName() { // arrange LoadSchematicRequest request = null; ISchematicServices implementation = null; var service = new SchematicServices(implementation); // act Assert.Throws <System.ArgumentNullException>(() => service.LoadSchematicFromFile(request)); }
public LoadSchematicResponse LoadSchematicFromFile(LoadSchematicRequest request) { ThrowIf.Argument.IsNull(request, "request"); ThrowIf.Argument.IsNull(request.Path, "path"); if (!services.FileExists(request.Path)) { throw new FileNotFoundException(); } return(new LoadSchematicResponse() { Schematic = services.LoadSchematicFromFile(request.Path) }); }
public void ShouldReturnErrorIfIPassBadFileName() { // arrange var request = new LoadSchematicRequest { Path = "goodFile.schematic" }; var badRequest = new LoadSchematicRequest { Path = "bad.schematic" }; ISchematicServices implementation = getServiceImplementation(request.Path); var service = new SchematicServices(implementation); // act Assert.Throws <System.IO.FileNotFoundException>(() => service.LoadSchematicFromFile(badRequest)); }
public void ShouldWorkInHappyCase() { // arrange var request = new LoadSchematicRequest { Path = "goodFile.schematic" }; ISchematicServices implementation = getServiceImplementation(request.Path); var service = new SchematicServices(implementation); // act var response = service.LoadSchematicFromFile(request); // assert Assert.IsTrue(response != null, "response should be defined"); implementation.Received().LoadSchematicFromFile(request.Path); }