Exemple #1
0
        public async void Shoould_Success_Get_Excel()
        {
            var            dbContext           = DbContext(GetCurrentMethod());
            var            serviceProviderMock = GetServiceProviderMock(dbContext);
            var            httpClientService   = new Mock <IHttpClientService>();
            DailyAPiResult dailyAPiResult      = new DailyAPiResult
            {
                data = new List <DailyOperationViewModel> {
                    new DailyOperationViewModel {
                        area          = "Test",
                        color         = "Color Test",
                        machine       = "Machine Test",
                        orderNo       = "a",
                        orderQuantity = 1,
                        step          = "Test"
                    }
                }
            };

            FabricAPiResult fabricAPiResult = new FabricAPiResult
            {
                data = new List <FabricQualityControlViewModel> {
                    new FabricQualityControlViewModel {
                        grade         = "Test",
                        orderNo       = "a",
                        orderQuantity = 1
                    }
                }
            };

            httpClientService.Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("finishing-printing/daily-operations/production-order-report"))))
            .ReturnsAsync(new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(dailyAPiResult))
            });
            httpClientService.Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("finishing-printing/quality-control/defect"))))
            .ReturnsAsync(new HttpResponseMessage(System.Net.HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(fabricAPiResult))
            });


            serviceProviderMock
            .Setup(x => x.GetService(typeof(IdentityService)))
            .Returns(new IdentityService {
                Username = "******", TimezoneOffset = 7
            });
            serviceProviderMock
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);
            ProductionOrderFacade facade = Activator.CreateInstance(typeof(ProductionOrderFacade), serviceProviderMock.Object, dbContext) as ProductionOrderFacade;
            FinishingPrintingSalesContractFacade    facadeSC   = new FinishingPrintingSalesContractFacade(serviceProviderMock.Object, dbContext);
            FinisihingPrintingSalesContractDataUtil dataUtilSC = new FinisihingPrintingSalesContractDataUtil(facadeSC);
            var data2 = await dataUtilSC.GetNewData();

            data2.SalesContractNo = "a";
            await facadeSC.CreateAsync(data2);

            var data = await DataUtil(facade).GetNewData();

            data.SalesContractId = data2.Id;
            data.SalesContractNo = data2.SalesContractNo;
            var model = await facade.CreateAsync(data);

            var tuple = await facade.GenerateExcel(data2.SalesContractNo, null, null, null, null, null, null, null, 7);

            Assert.IsType <System.IO.MemoryStream>(tuple);
        }
Exemple #2
0
        protected override Mock <IServiceProvider> GetServiceProviderMock(SalesDbContext dbContext)
        {
            var serviceProviderMock = new Mock <IServiceProvider>();

            IIdentityService identityService = new IdentityService {
                Username = "******"
            };

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IIdentityService)))
            .Returns(identityService);

            var            httpClientService = new Mock <IHttpClientService>();
            DailyAPiResult dailyAPiResult    = new DailyAPiResult
            {
                data = new List <DailyOperationViewModel> {
                    new DailyOperationViewModel {
                        area          = "Test",
                        color         = "Color Test",
                        machine       = "Machine Test",
                        orderNo       = "a",
                        orderQuantity = 1,
                        step          = "Test"
                    }
                }
            };

            FabricAPiResult fabricAPiResult = new FabricAPiResult
            {
                data = new List <FabricQualityControlViewModel> {
                    new FabricQualityControlViewModel {
                        grade         = "Test",
                        orderNo       = "a",
                        orderQuantity = 1
                    }
                }
            };

            httpClientService.Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("finishing-printing/daily-operations/production-order-report"))))
            .ReturnsAsync(new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(dailyAPiResult))
            });
            httpClientService.Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("finishing-printing/quality-control/defect"))))
            .ReturnsAsync(new HttpResponseMessage(System.Net.HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(fabricAPiResult))
            });


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

            var ccLogic = new FinishingPrintingCostCalculationLogic(identityService, dbContext);

            serviceProviderMock.Setup(s => s.GetService(typeof(FinishingPrintingCostCalculationLogic)))
            .Returns(ccLogic);

            var preSalesContractLogic = new FinishingPrintingPreSalesContractLogic(identityService, dbContext);

            serviceProviderMock
            .Setup(s => s.GetService(typeof(FinishingPrintingPreSalesContractLogic)))
            .Returns(preSalesContractLogic);

            var productionOrderDetailLogic = new ProductionOrder_DetailLogic(serviceProviderMock.Object, identityService, dbContext);
            var productionOrderlsLogic     = new ProductionOrder_LampStandardLogic(serviceProviderMock.Object, identityService, dbContext);
            var productionOrderrwLogic     = new ProductionOrder_RunWidthLogic(serviceProviderMock.Object, identityService, dbContext);

            var poDetailMock = new Mock <ProductionOrder_DetailLogic>();
            var poRWk        = new Mock <ProductionOrder_RunWidthLogic>();
            var poLSMock     = new Mock <ProductionOrder_LampStandardLogic>();

            serviceProviderMock
            .Setup(x => x.GetService(typeof(ProductionOrder_DetailLogic)))
            .Returns(productionOrderDetailLogic);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(ProductionOrder_LampStandardLogic)))
            .Returns(productionOrderlsLogic);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(ProductionOrder_RunWidthLogic)))
            .Returns(productionOrderrwLogic);


            var finishingprintingDetailObject = new FinishingPrintingSalesContractDetailLogic(serviceProviderMock.Object, identityService, dbContext);
            var finishingprintingLogic        = new ShinFinishingPrintingSalesContractLogic(finishingprintingDetailObject, serviceProviderMock.Object, identityService, dbContext);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(ShinFinishingPrintingSalesContractLogic)))
            .Returns(finishingprintingLogic);

            var productionOrderLogic = new ShinProductionOrderLogic(serviceProviderMock.Object, identityService, dbContext);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(ShinProductionOrderLogic)))
            .Returns(productionOrderLogic);

            var azureImageFacadeMock = new Mock <IAzureImageFacade>();

            azureImageFacadeMock
            .Setup(s => s.DownloadImage(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync("");

            azureImageFacadeMock
            .Setup(s => s.UploadImage(It.IsAny <string>(), It.IsAny <long>(), It.IsAny <DateTime>(), It.IsAny <string>()))
            .ReturnsAsync("");

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IAzureImageFacade)))
            .Returns(azureImageFacadeMock.Object);

            return(serviceProviderMock);
        }