Beispiel #1
0
        public async Task Should_Success_GetImportPurchasingBookReport_Pdf()
        {
            var mockFacade = new Mock <IImportPurchasingBookReportFacade>();

            mockFacade.Setup(facade => facade.GetReportV2(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <int>())).ReturnsAsync(new LocalPurchasingBookReportViewModel()
            {
                CategorySummaries = new List <Summary>()
                {
                    new Summary {
                        AccountingLayoutIndex = 0, Category = "test", CurrencyCode = "test", SubTotal = 10, SubTotalCurrency = 10
                    }
                },
                CategorySummaryTotal = 1,
                CurrencySummaries    = new List <Summary>()
                {
                    new Summary {
                        AccountingLayoutIndex = 0, Category = "test", CurrencyCode = "test", SubTotal = 10, SubTotalCurrency = 10
                    }
                },
                GrandTotal = 1,
                Reports    = new List <PurchasingReport>()
                {
                    new PurchasingReport {
                        URNNo = "test", CategoryCode = "test", CategoryName = "test", CurrencyCode = "test", AccountingUnitName = "test", AccountingCategoryName = "test"
                    }
                }
            });

            var controller = new ImportPurchasingBookReportController(mockFacade.Object)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                    }
                }
            };

            controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "1";
            var response = await controller.GetPdf(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <int>());

            Assert.NotNull(response);
        }
Beispiel #2
0
        public async Task Should_Failed_GetImportPurchasingBookReport_Pdf_WithException()
        {
            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>())).ThrowsAsync(new Exception());

            var controller = new ImportPurchasingBookReportController(mockFacade.Object)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                    }
                }
            };

            controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "1";
            var response = await controller.GetPdf(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>());

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }