public async Task Should_Error_GetReport_PaymentStatus()
        {
            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);

            Assert.ThrowsAny <Exception>(() => facadepaymentstatus.GetReport(null, null, null, null, null, null, null, null, null, null, null, null, 1, 25, "{}", 7));
        }
Beispiel #2
0
        public async Task Should_Success_Get_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 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 serviceProvider = GetServiceProvider().Object;
            var dbContext       = _dbContext(GetCurrentMethod());
            GarmentDeliveryOrderFacade facade = new GarmentDeliveryOrderFacade(serviceProvider, dbContext);
            var datautilDO = dataUtil(facade, GetCurrentMethod());

            var garmentbeacukaiFacade = new GarmentBeacukaiFacade(_dbContext(GetCurrentMethod()), GetServiceProvider().Object);
            var dataUtilBC            = new GarmentBeacukaiDataUtil(datautilDO, garmentbeacukaiFacade);

            var invoicefacade = new GarmentInvoiceFacade(dbContext, serviceProvider);
            var garmentInvoiceDetailDataUtil = new GarmentInvoiceDetailDataUtil();
            var garmentInvoiceItemDataUtil   = new GarmentInvoiceItemDataUtil(garmentInvoiceDetailDataUtil);
            var dataUtilInvoice = new GarmentInvoiceDataUtil(garmentInvoiceItemDataUtil, garmentInvoiceDetailDataUtil, datautilDO, invoicefacade);

            var internnotefacade   = new GarmentInternNoteFacades(dbContext, serviceProvider);
            var datautilinternnote = new GarmentInternNoteDataUtil(dataUtilInvoice, internnotefacade);

            var correctionfacade = new GarmentCorrectionNotePriceFacade(serviceProviderMock.Object, dbContext);

            var CorrectionNote = new GarmentCorrectionNoteDataUtil(correctionfacade, datautilDO);

            var dataDO = await datautilDO.GetNewData();

            //dataDO.IsCorrection = true;
            await facade.Create(dataDO, USERNAME);

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

            var dataCorrection = await CorrectionNote.GetTestData(dataDO);

            //await correctionfacade.Create(dataCorrection);
            var dataInvo = await dataUtilInvoice.GetTestData2(USERNAME, dataDO);

            var dataintern = await datautilinternnote.GetNewData(dataInvo);

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

            //var g =  $"{nowTicksA}"
            var bookReportFacade = new GarmentPurchasingBookReportFacade(serviceProvider, dbContext);
            var Response         = bookReportFacade.GetBookReport(7, null, null, null, 0, 0, "{}", null, null);

            Assert.NotNull(Response.Item1);
        }