Esempio n. 1
0
        public async Task Should_Success_Get_Excel()
        {
            var mockServiceProvider = GetMockServiceProvider();

            var dbContext = GetDbContext(GetCurrentMethod());

            var garmentPOMasterDistributionFacade = new GarmentPOMasterDistributionFacade(mockServiceProvider.Object, dbContext);
            var dataGarmentPOMasterDistribution   = await dataUtil(garmentPOMasterDistributionFacade, dbContext).GetTestData();

            var costCalculationGarmentDataUtil = new CostCalculationGarmentDataUtil();
            var ccData = costCalculationGarmentDataUtil.GetNewData();

            ccData.CostCalculationGarment_Materials.First().PO_SerialNumber = dataGarmentPOMasterDistribution.Items.First().Details.First().POSerialNumber;
            var ccData2 = costCalculationGarmentDataUtil.GetNewData();

            ccData.CostCalculationGarment_Materials.Add(ccData2.CostCalculationGarment_Materials.First());

            var mockHttpClientService = GetMockHttpClientService();

            mockHttpClientService
            .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("cost-calculation-garments"))))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(costCalculationGarmentDataUtil.GetResultFormatterOkString(ccData))
            });
            mockServiceProvider
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(mockHttpClientService.Object);

            var facade = new MonitoringROJobOrderFacade(mockServiceProvider.Object, dbContext);

            var Response = await facade.GetExcel(dataGarmentPOMasterDistribution.Id);

            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);
        }
Esempio n. 3
0
        protected CostCalculationGarmentDataUtil DataUtil(CostCalculationGarmentFacade facade, SalesDbContext dbContext = null)
        {
            var serviceProvider = GetServiceProviderMock(dbContext).Object;

            GarmentPreSalesContractFacade   garmentPreSalesContractFacade   = new GarmentPreSalesContractFacade(serviceProvider, dbContext);
            GarmentPreSalesContractDataUtil garmentPreSalesContractDataUtil = new GarmentPreSalesContractDataUtil(garmentPreSalesContractFacade);

            CostCalculationGarmentDataUtil costCalculationGarmentDataUtil = new CostCalculationGarmentDataUtil(facade, garmentPreSalesContractDataUtil);

            return(costCalculationGarmentDataUtil);
        }
        protected override GarmentSalesContractDataUtil DataUtil(GarmentSalesContractFacade facade, SalesDbContext dbContext = null)
        {
            var serviceProvider = GetServiceProviderMock(dbContext);
            CostCalculationGarmentFacade    ccFacade    = new CostCalculationGarmentFacade(serviceProvider.Object, dbContext);
            GarmentPreSalesContractFacade   gpsCFacade  = new GarmentPreSalesContractFacade(serviceProvider.Object, dbContext);
            GarmentPreSalesContractDataUtil gpCDataUtil = new GarmentPreSalesContractDataUtil(gpsCFacade);
            CostCalculationGarmentDataUtil  ccDataUtil  = new CostCalculationGarmentDataUtil(ccFacade, gpCDataUtil);
            GarmentSalesContractDataUtil    dataUtil    = Activator.CreateInstance(typeof(GarmentSalesContractDataUtil), facade, ccDataUtil) as GarmentSalesContractDataUtil;

            return(dataUtil);
        }
        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 GarmentSalesContractDataUtil(GarmentSalesContractFacade facade, CostCalculationGarmentDataUtil costCalculationGarmentDataUtil) : base(facade)
 {
     this.costCalculationGarmentDataUtil = costCalculationGarmentDataUtil;
 }
Esempio n. 7
0
 public ROGarmentDataUtil(ROGarmentFacade facade, CostCalculationGarmentDataUtil costCalculationGarmentDataUtil) : base(facade)
 {
     this.costCalculationGarmentDataUtil = costCalculationGarmentDataUtil;
 }