public async Task Should_Failed_GetLocalPurchasingBookReportXls() { var mockFacade = new Mock <IImportPurchasingBookReportFacade>(); mockFacade.Setup(facade => facade.GenerateExcel(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>())).ReturnsAsync(new MemoryStream()); var controller = new ImportPurchasingBookReportController(mockFacade.Object); var response = await controller.Get(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>()); Assert.NotNull(response); }
public async Task Should_Failed_GetLocalPurchasingBookReportXls_WithException() { var mockFacade = new Mock <IImportPurchasingBookReportFacade>(); mockFacade.Setup(facade => facade.GenerateExcel(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>())).ThrowsAsync(new Exception()); var controller = new ImportPurchasingBookReportController(mockFacade.Object); var response = await controller.Get(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>()); Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response)); }
public async Task Should_Success_GetLocalPurchasingBookReport() { var mockFacade = new Mock <IImportPurchasingBookReportFacade>(); mockFacade.Setup(facade => facade.GetReport(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>())).ReturnsAsync(new LocalPurchasingBookReportViewModel()); var controller = new ImportPurchasingBookReportController(mockFacade.Object); var response = await controller.Get(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>()); Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response)); }