public void RenderReport_WhenContain19VouchersInSameTransaction_Print2HeaderAnd19Row() { // Arrange var items = new List<AllItem>(); for (int i = 0; i < 19; i++) { items.Add(new AllItem() { TransactionNumber = "001" }); } repository.Setup(s => s.GetAllItems(It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>())) .Returns(items); fileSystem.Setup(s => s.File.ReadAllText(It.IsAny<string>())); reportHelper.Setup(s => s.IsStartNewPage(0)).Returns(true); reportHelper.Setup(s => s.IsStartNewPage(18)).Returns(true); var reportGenerator = new AllItemsReportGenerator(fileSystem.Object, repository.Object, reportHelper.Object); // Act var response = reportGenerator.RenderReport(reportRequest, "outputFolderPath"); // Assert Assert.IsTrue(response.IsSuccessful); reportHelper.Verify(p => p.PrintPageHeader(It.IsAny<StreamWriter>(), It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(2)); reportHelper.Verify(p => p.PrintReportRow(It.IsAny<StreamWriter>(), It.IsAny<AllItem>()), Times.Exactly(19)); }
public void RenderReport_WhenVouchersAreEmpty_PrintEmptyReportIsCalledOnce() { repository.Setup(s => s.GetAllItems(It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>())) .Returns(new List<AllItem>()); fileSystem.Setup(s => s.File.ReadAllText(It.IsAny<string>())); var reportGenerator = new AllItemsReportGenerator(fileSystem.Object, repository.Object, reportHelper.Object); var response = reportGenerator.RenderReport(reportRequest, "outputFolderPath"); Assert.IsTrue(response.IsSuccessful); reportHelper.Verify(p => p.PrintEmptyReport( It.IsAny<StreamWriter>(), It.IsAny<DateTime>(), It.IsAny<string>()), Times.Once); }