Пример #1
0
        public async Task Should_Success_Get_Excel_Book_Report()
        {
            var httpClientService = new Mock <IHttpClientService>();

            httpClientService.Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("master/garment-suppliers"))))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(new CurrencyDataUtil().GetResultFormatterOkString())
            });
            var serviceProviderMock = new Mock <IServiceProvider>();

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IdentityService)))
            .Returns(new IdentityService {
                Username = "******", TimezoneOffset = 7
            });
            serviceProviderMock
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);

            var serviceProvider = GetServiceProvider().Object;
            var dbContext       = _dbContext(GetCurrentMethod());
            GarmentDeliveryOrderFacade facade = new GarmentDeliveryOrderFacade(serviceProvider, dbContext);
            var dataUtilDO                   = dataUtil(facade, GetCurrentMethod());
            var garmentBeacukaiFacade        = new GarmentBeacukaiFacade(dbContext, serviceProvider);
            var dataUtilBC                   = new GarmentBeacukaiDataUtil(dataUtilDO, garmentBeacukaiFacade);
            var invoicefacade                = new GarmentInvoiceFacade(dbContext, serviceProvider);
            var garmentInvoiceDetailDataUtil = new GarmentInvoiceDetailDataUtil();
            var garmentinvoiceItemDataUtil   = new GarmentInvoiceItemDataUtil(garmentInvoiceDetailDataUtil);
            var dataUtilInvo                 = new GarmentInvoiceDataUtil(garmentinvoiceItemDataUtil, garmentInvoiceDetailDataUtil, dataUtilDO, invoicefacade);
            var internnotefacade             = new GarmentInternNoteFacades(dbContext, serviceProvider);
            var dataUtilInternNote           = new GarmentInternNoteDataUtil(dataUtilInvo, internnotefacade);
            var correctionfacade             = new GarmentCorrectionNotePriceFacade(serviceProviderMock.Object, dbContext);
            var correctionDataUtil           = new GarmentCorrectionNoteDataUtil(correctionfacade, dataUtilDO);

            var dataDO = await dataUtilDO.GetNewData();

            await facade.Create(dataDO, USERNAME);

            var dataBC = await dataUtilBC.GetTestData(USERNAME, dataDO);

            var dataCorrection = await correctionDataUtil.GetTestData(dataDO);

            var dataInvo = await dataUtilInvo.GetTestData2(USERNAME, dataDO);

            var dataIntern = await dataUtilInternNote.GetNewData(dataInvo);

            await internnotefacade.Create(dataIntern, false, "Unit Test");

            var bookReportFacade = new GarmentPurchasingBookReportFacade(serviceProvider, dbContext);
            var Response         = bookReportFacade.GenerateExcelBookReport(null, null, null, null, null, 7);

            Assert.IsType <System.IO.MemoryStream>(Response);
        }
        public async Task Should_Error_Get_Xls_Payment()
        {
            var httpClientService = new Mock <IHttpClientService>();

            httpClientService.Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("master/garment-suppliers"))))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(new SupplierDataUtil().GetResultFormatterOkString())
            });
            httpClientService
            .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("master/garment-currencies"))))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(new CurrencyDataUtil().GetMultipleResultFormatterOkString())
            });

            var serviceProviderMock = new Mock <IServiceProvider>();

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IdentityService)))
            .Returns(new IdentityService {
                Username = "******", TimezoneOffset = 7
            });
            serviceProviderMock
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);
            var dbContext = _dbContext(GetCurrentMethod());
            //var serviceProvider = GetServiceProvider().Object;

            var facade = new GarmentInternNoteFacades(dbContext, serviceProviderMock.Object);
            var garmentcorrectionfacade            = new Lib.Facades.GarmentCorrectionNoteFacades.GarmentCorrectionNotePriceFacade(serviceProviderMock.Object, dbContext);
            var garmentPurchaseRequestFacade       = new GarmentPurchaseRequestFacade(serviceProviderMock.Object, dbContext);
            var garmentInternalPurchaseOrderFacade = new GarmentInternalPurchaseOrderFacade(dbContext);
            var garmentExternalPurchaseOrderFacade = new GarmentExternalPurchaseOrderFacade(serviceProviderMock.Object, dbContext);
            var garmentDeliveryOrderFacade         = new GarmentDeliveryOrderFacade(serviceProviderMock.Object, dbContext);
            var garmentInvoiceFacade         = new GarmentInvoiceFacade(dbContext, serviceProviderMock.Object);
            var prdatautil                   = new GarmentPurchaseRequestDataUtil(garmentPurchaseRequestFacade);
            var internalPoDatautil           = new GarmentInternalPurchaseOrderDataUtil(garmentInternalPurchaseOrderFacade, prdatautil);
            var datautilexpo                 = new GarmentExternalPurchaseOrderDataUtil(garmentExternalPurchaseOrderFacade, internalPoDatautil);
            var dataUtilDo                   = new GarmentDeliveryOrderDataUtil(garmentDeliveryOrderFacade, datautilexpo);
            var garmentInvoiceDetailDataUtil = new GarmentInvoiceDetailDataUtil();
            var garmentInvoiceItemDataUtil   = new GarmentInvoiceItemDataUtil(garmentInvoiceDetailDataUtil);
            var garmentInvoieDataUtil        = new GarmentInvoiceDataUtil(garmentInvoiceItemDataUtil, garmentInvoiceDetailDataUtil, dataUtilDo, garmentInvoiceFacade);
            var corecctiondatautil           = new GarmentCorrectionNoteDataUtil(garmentcorrectionfacade, dataUtilDo);

            var dataDo = await dataUtilDo.GetTestData();

            var dataCorr = await corecctiondatautil.GetTestData(dataDo);

            var invoData = await garmentInvoieDataUtil.GetTestData2("Test", dataDo);

            var dataIntern = await dataUtil(facade, GetCurrentMethod()).GetNewData(invoData);

            dataIntern.Items.FirstOrDefault().Details.FirstOrDefault().PaymentDueDate = DateTimeOffset.Now;
            await facade.Create(dataIntern, false, "Unit Test");

            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("Nomor", typeof(string));
            dataTable.Columns.Add("Tgl", typeof(DateTime));
            dataTable.Columns.Add("Jumlah", typeof(decimal));
            dataTable.Rows.Add("Nomor", "1970,1,1", 0);

            Mock <ILocalDbCashFlowDbContext> mockDbContext = new Mock <ILocalDbCashFlowDbContext>();

            mockDbContext.Setup(s => s.ExecuteReaderOnlyQuery(It.IsAny <string>()))
            .Throws(new Exception("Error ExecuteReader"));
            mockDbContext.Setup(s => s.ExecuteReader(It.IsAny <string>(), It.IsAny <List <SqlParameter> >()))
            .Throws(new Exception("Error ExecuteReader"));

            var facadepaymentstatus = new GarmentInternNotePaymentStatusFacade(serviceProviderMock.Object, dbContext, mockDbContext.Object);
            var Response            = Assert.ThrowsAny <Exception>(() => facadepaymentstatus.GetXLs(null, null, null, null, null, null, null, null, DateTime.Now.AddDays(1), null, DateTime.Now.AddDays(1), null, 7));

            Assert.NotNull(Response);
        }