public async void Get_Success_Excel()
        {
            var dbContext           = DbContext(GetCurrentMethod());
            var serviceProviderMock = GetServiceProviderMock(dbContext);

            var serviceProvider = serviceProviderMock.Object;

            GarmentPreSalesContractFacade   garmentPreSalesContractFacade   = new GarmentPreSalesContractFacade(serviceProvider, dbContext);
            GarmentPreSalesContractDataUtil garmentPreSalesContractDataUtil = new GarmentPreSalesContractDataUtil(garmentPreSalesContractFacade);
            var garmentPreSalesContractData1 = await garmentPreSalesContractDataUtil.GetNewData();

            await garmentPreSalesContractDataUtil.GetTestData(garmentPreSalesContractData1);

            var garmentPreSalesContractData2 = await garmentPreSalesContractDataUtil.GetNewData();

            await garmentPreSalesContractDataUtil.GetTestData(garmentPreSalesContractData2);

            var garmentPreSalesContractData3 = await garmentPreSalesContractDataUtil.GetNewData();

            await garmentPreSalesContractDataUtil.GetTestData(garmentPreSalesContractData3);

            CostCalculationGarmentFacade   costCalculationGarmentFacade   = new CostCalculationGarmentFacade(serviceProvider, dbContext);
            CostCalculationGarmentDataUtil costCalculationGarmentDataUtil = new CostCalculationGarmentDataUtil(costCalculationGarmentFacade, garmentPreSalesContractDataUtil);
            var costCalculationGarmentData11 = await costCalculationGarmentDataUtil.GetNewData(garmentPreSalesContractData1);

            await costCalculationGarmentDataUtil.GetTestData(costCalculationGarmentData11);

            var costCalculationGarmentData12 = await costCalculationGarmentDataUtil.GetNewData(garmentPreSalesContractData1);

            await costCalculationGarmentDataUtil.GetTestData(costCalculationGarmentData12);

            var costCalculationGarmentData2 = await costCalculationGarmentDataUtil.GetNewData(garmentPreSalesContractData2);

            await costCalculationGarmentDataUtil.GetTestData(costCalculationGarmentData2);

            Mock <IHttpClientService> httpClientServiceMock = new Mock <IHttpClientService>();

            httpClientServiceMock
            .Setup(x => x.GetAsync(It.IsAny <string>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent("{ data: [{ SCNo: \"" + garmentPreSalesContractData1.SCNo + "\", Unit: { Name: \"" + garmentPreSalesContractData1.SCNo + "\" } }, { SCNo: \"" + garmentPreSalesContractData2.SCNo + "\", Unit: { Name: \"" + garmentPreSalesContractData2.SCNo + "\" } }, { SCNo: \"" + garmentPreSalesContractData2.SCNo + "\", Unit: { Name: \"" + garmentPreSalesContractData2.SCNo + "\" } }] }", Encoding.UTF8, General.JsonMediaType)
            });

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(httpClientServiceMock.Object);

            var facade = new MonitoringPreSalesContractFacade(serviceProviderMock.Object);

            var Response = facade.GenerateExcel();

            Assert.NotNull(Response.Item2);
        }
        public async void Get_Success_With_Filter()
        {
            var dbContext           = DbContext(GetCurrentMethod());
            var serviceProviderMock = GetServiceProviderMock(dbContext);

            var serviceProvider = serviceProviderMock.Object;

            GarmentPreSalesContractFacade   garmentPreSalesContractFacade   = new GarmentPreSalesContractFacade(serviceProvider, dbContext);
            GarmentPreSalesContractDataUtil garmentPreSalesContractDataUtil = new GarmentPreSalesContractDataUtil(garmentPreSalesContractFacade);
            var garmentPreSalesContractData = await garmentPreSalesContractDataUtil.GetNewData();

            await garmentPreSalesContractDataUtil.GetTestData(garmentPreSalesContractData);

            CostCalculationGarmentFacade   costCalculationGarmentFacade   = new CostCalculationGarmentFacade(serviceProvider, dbContext);
            CostCalculationGarmentDataUtil costCalculationGarmentDataUtil = new CostCalculationGarmentDataUtil(costCalculationGarmentFacade, garmentPreSalesContractDataUtil);
            var costCalculationGarmentData = await costCalculationGarmentDataUtil.GetNewData(garmentPreSalesContractData);

            await costCalculationGarmentDataUtil.GetTestData(costCalculationGarmentData);

            var filter = new
            {
                section    = garmentPreSalesContractData.SectionCode,
                preSCNo    = garmentPreSalesContractData.SCNo,
                preSCType  = garmentPreSalesContractData.SCType,
                buyerAgent = garmentPreSalesContractData.BuyerAgentCode,
                buyerBrand = garmentPreSalesContractData.BuyerBrandCode,

                prNoMaster = "PRNo",
                roNoMaster = "RONo",
                unitMaster = "Unit",

                roNoJob = costCalculationGarmentData.RO_Number,
                unitJob = costCalculationGarmentData.UnitCode,

                dateStart = garmentPreSalesContractData.SCDate,
                dateEnd   = garmentPreSalesContractData.SCDate
            };

            Mock <IHttpClientService> httpClientServiceMock = new Mock <IHttpClientService>();

            httpClientServiceMock
            .Setup(x => x.GetAsync(It.IsAny <string>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent("{ data: [{ PRNo: \"" + filter.prNoMaster + "\", RONo: \"" + filter.roNoMaster + "\", SCNo: \"" + filter.preSCNo + "\", Unit: { Name: \"" + filter.unitMaster + "\" } }] }", Encoding.UTF8, General.JsonMediaType)
            });

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(httpClientServiceMock.Object);

            var facade = new MonitoringPreSalesContractFacade(serviceProviderMock.Object);

            var Response = facade.Read(filter: JsonConvert.SerializeObject(filter));

            Assert.NotEqual(Response.Item2, 0);
        }
        public override async Task <GarmentSalesContract> GetNewData()
        {
            var costCalculationGarmentData = await costCalculationGarmentDataUtil.GetTestData();

            var data = await base.GetNewData();

            data.SalesContractNo   = "SC/DL/001";
            data.CostCalculationId = (int)costCalculationGarmentData.Id;
            data.RONumber          = costCalculationGarmentData.RO_Number;
            data.DeliveryDate      = costCalculationGarmentData.DeliveryDate;
            data.Article           = costCalculationGarmentData.Article;
            data.BuyerBrandId      = costCalculationGarmentData.BuyerBrandId;
            data.BuyerBrandCode    = costCalculationGarmentData.BuyerBrandCode;
            data.BuyerBrandName    = costCalculationGarmentData.BuyerBrandName;
            data.ComodityId        = 1;
            data.ComodityCode      = "XX";
            data.ComodityName      = "Test Comodity";
            data.Packing           = "Text Packing";
            data.Quantity          = 1;
            data.UomId             = "1";
            data.UomUnit           = "Test UOM";
            data.Description       = "Test Description";
            data.Material          = "Test Material";
            data.DocPresented      = "Test DocPresented";
            data.FOB           = "Test";
            data.Price         = 8.7;
            data.Amount        = 8.7;
            data.Delivery      = "Test";
            data.Country       = "Test";
            data.NoHS          = "Test No HS";
            data.IsMaterial    = false;
            data.IsTrimming    = false;
            data.IsEmbrodiary  = false;
            data.IsPrinted     = false;
            data.IsTTPayment   = false;
            data.PaymentDetail = "Test Payment";
            data.AccountBankId = 1;
            data.AccountName   = "Test Account Name";
            data.DocPrinted    = false;

            data.Items = new List <GarmentSalesContractItem>()
            {
                new GarmentSalesContractItem
                {
                    Quantity    = 1,
                    Price       = 8.7,
                    Description = "Test",
                }
            };
            return(data);
        }
Exemplo n.º 4
0
        public override async Task <RO_Garment> GetNewData()
        {
            var costCalculation = await costCalculationGarmentDataUtil.GetTestData();

            var data = await base.GetNewData();

            data.CostCalculationGarment   = costCalculation;
            data.CostCalculationGarmentId = costCalculation.Id;

            data.Code        = "test";
            data.Instruction = "test";
            data.Total       = 1;
            data.ImagesPath  = "[\"/sales/RO_Garment/IMG_1_0_201907300436141716\"]";
            data.RO_Garment_SizeBreakdowns = new List <RO_Garment_SizeBreakdown>()
            {
                new RO_Garment_SizeBreakdown
                {
                    RO_GarmentId = data.Id,
                    Code         = "FABRIC",
                    ColorId      = 1,
                    ColorName    = "test",
                    Total        = 1,
                    RO_Garment_SizeBreakdown_Details = new List <RO_Garment_SizeBreakdown_Detail>()
                    {
                        new RO_Garment_SizeBreakdown_Detail
                        {
                            Code        = "FABRIC",
                            Information = "test",
                            Size        = "L",
                            Quantity    = 1
                        }
                    }
                }
            };

            return(data);
        }