public async Task GenerateTest() { //Arrange var dateTime = new DateTime(2013, 4, 1); var domains=new List<DomainReport>(); var reportService = new Mock<IStandardReportService>(); var reportBuilder = new Mock<IReportBuilderService>(); var reportGenerator = new ReportGenerator(reportService.Object, reportBuilder.Object); reportBuilder.Setup(m => m.BuildReports(dateTime)).Returns(domains); reportService.Setup(m => m.WriteReports(domains, dateTime)).Returns(async () => { }); //Act & Assert await reportGenerator.Generate(dateTime); }
public async Task GenerateIfNotExistReportExistTest() { //Arrange var dateTime = new DateTime(2013, 4, 1); var domains = new List<DomainReport>(); var reportService = new Mock<IStandardReportService>(); var reportBuilder = new Mock<IReportBuilderService>(); var reportGenerator = new ReportGenerator(reportService.Object, reportBuilder.Object); reportBuilder.Setup(m => m.BuildReports(dateTime)).Returns(domains); reportService.Setup(m => m.GetReports(dateTime)).Returns(async () => domains); //Act & Assert await reportGenerator.GenerateIfNotExist(dateTime); //Assert reportBuilder.Verify(m => m.BuildReports(It.IsAny<DateTime>()), Times.Never()); }