示例#1
0
        public ShinProductionOrderFacade(IServiceProvider serviceProvider, SalesDbContext dbContext)
        {
            this.DbContext            = dbContext;
            _serviceProvider          = serviceProvider;
            this.DbSet                = DbContext.Set <ProductionOrderModel>();
            this.productionOrderLogic = serviceProvider.GetService <ShinProductionOrderLogic>();
            this.finishingPrintingSalesContractLogic = serviceProvider.GetService <ShinFinishingPrintingSalesContractLogic>();

            this.identityService = serviceProvider.GetService <IIdentityService>();
        }
示例#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);
        }
 public ShinFinishingPrintingSalesContractFacade(IServiceProvider serviceProvider, SalesDbContext dbContext)
 {
     DbContext = dbContext;
     DbSet     = DbContext.Set <FinishingPrintingSalesContractModel>();
     finishingPrintingSalesContractLogic = serviceProvider.GetService <ShinFinishingPrintingSalesContractLogic>();
 }