public void StartPhysicalPrint_MustReturnCardDataIsFalse_PrinterHasMagEncoderToCheckBIN_BinDoesNotMatchCardInserted() { // Arrange var printJob = Substitute.For <IPrintJob>(); printJob.MustReturnCardData.Returns(false); var printingWebService = Substitute.For <ICardPrinting>(); var printDetails = Substitute.For <ICardPrintDetails>(); var printer = Substitute.For <IPrinter>(); printer.Print("productBin", printDetails).ReturnsForAnyArgs(PrinterCodes.ProductBinAndCardMismatch); var cardPrintLogic = new CardPrintingLogic(printingWebService, printer); // Act CardData cardData = null; string additionalInfo; var success = cardPrintLogic.StartPhysicalPrint(printJob, out cardData, out additionalInfo); // Assert printer.ReceivedWithAnyArgs(1).Print("productCode", printDetails); IDeviceMagData magData; printer.DidNotReceiveWithAnyArgs().ReadAndPrint("productCode", printDetails, out magData); success.Should().BeFalse(); cardData.Should().BeNull(because: "PrintJob object has property MustReturnCardData set to false. therefore we are not expecting to recceive a populated CardData object"); }
public void StartPhysicalPrint_MustReturnCardDataIsTrue_PanAndTrack2SetCorrectly_SuccessfulReadAndPrint() { // Arrange var printJob = Substitute.For <IPrintJob>(); printJob.MustReturnCardData.Returns(true); var printingWebService = Substitute.For <ICardPrinting>(); var printDetails = Substitute.For <ICardPrintDetails>(); var rtnMagData = Substitute.For <IDeviceMagData>(); rtnMagData.TrackDataToString(2).Returns("1234567890123456=ThisIsTrack2"); var printer = Substitute.For <IPrinter>(); IDeviceMagData tempMagData; printer.ReadAndPrint("productBin", printDetails, out tempMagData).ReturnsForAnyArgs(x => { x[2] = rtnMagData; return(PrinterCodes.Success); }); var cardPrintLogic = new CardPrintingLogic(printingWebService, printer); // Act CardData cardData = null; string additionalInfo; var success = cardPrintLogic.StartPhysicalPrint(printJob, out cardData, out additionalInfo); // Assert IDeviceMagData magData; printer.ReceivedWithAnyArgs(1).ReadAndPrint("productCode", printDetails, out magData); printer.DidNotReceiveWithAnyArgs().Print("productCode", printDetails); success.Should().BeTrue(); cardData.Should().NotBeNull(because: "PrintJob object has property MustReturnCardData set to true. therefore we are expecting to recceive a populated CardData object on successful print"); cardData.Track2.Should().Be("1234567890123456=ThisIsTrack2"); cardData.PAN.Should().Be("1234567890123456"); }