public void GetPrintJob_ICardPrintingGetPrintJobUnsuccessful_ReturnPrintJobObject() { // Arrange var printingWebService = Substitute.For <ICardPrinting>(); printingWebService.GetPrintJob(new Token(), new PrinterInfo()).ReturnsForAnyArgs(new Response <PrintJob> { AdditionalInfo = "Call was not successful", Session = "SessionString", Success = false, Value = new PrintJob() }); var printer = Substitute.For <IPrinter>(); var cardPrintLogic = new CardPrintingLogic(printingWebService, printer); var token = new Token(); var printerInfo = new PrinterInfo(); // Act string additionalInfo; IPrintJob printJob = null; var success = cardPrintLogic.GetPrintJob(token, out printJob, out additionalInfo); // Assert success.Should().BeFalse(because: "The call to ICardPrinting returns success as false. Which should mean the calling method is unsuccessful"); printJob.Should().BeNull(because: "UnSuccessful call to ICardPrinting. Calling method should return a null PrintJob in output argument"); }
public void GetPrintJob_ICardPrintingGetPrintJobSuccess_ReturnsValidPrintJob() { // Arrange var printer = Substitute.For <IPrinter>(); var token = new Token { DeviceID = "DeviceId", Session = "Session", Workstation = "Workstation" }; // TODO: PrinterInfo need to be built from information from IPrinter var printerInfo = new PrinterInfo(); var printingWebService = Substitute.For <ICardPrinting>(); printingWebService.GetPrintJob(token, printerInfo).Returns(new Response <PrintJob> { AdditionalInfo = "Call was successful", Session = "SessionString", Success = true, Value = new PrintJob() }); var cardPrintLogic = new CardPrintingLogic(printingWebService, printer); // Act string additionalInfo; IPrintJob printJob = null; var success = cardPrintLogic.GetPrintJob(token, out printJob, out additionalInfo); // Assert printingWebService.Received().GetPrintJob(token, printerInfo); success.Should().BeTrue(because: "The call to ICardPrinting returns success as true. Which should mean the calling method is successful"); printJob.Should().NotBeNull(because: "Successful call to ICardPrinting should return a PrintJob object returned in output argument"); }