예제 #1
0
        public async void Validate_ViewModel()
        {
            var dbContext = DbContext(GetCurrentMethod());
            var vm        = new ShinProductionOrderViewModel()
            {
                Code = "a",
                ArticleFabricEdge = "a",
                DeliveryDate      = DateTimeOffset.UtcNow,
                Remark            = "a",
                ApprovalMD        = new ApprovalViewModel()
                {
                    ApprovedBy   = "a",
                    ApprovedDate = DateTimeOffset.UtcNow,
                    IsApproved   = true
                },
                IsCalculated   = true,
                IsClosed       = true,
                IsCompleted    = true,
                IsRequested    = true,
                IsUsed         = true,
                AutoIncreament = 0
            };
            var sp = GetServiceProviderMock(DbContext(GetCurrentMethod()));

            var facade = new ShinProductionOrderFacade(sp.Object, dbContext);

            sp.Setup(s => s.GetService(typeof(IShinProductionOrder)))
            .Returns(facade);

            var validationContext = new System.ComponentModel.DataAnnotations.ValidationContext(vm, sp.Object, null);
            var response          = vm.Validate(validationContext);

            Assert.NotEmpty(response);

            vm.FinishingPrintingSalesContract = new ShinFinishingPrintingSalesContractViewModel()
            {
                Id = 1,
                PreSalesContract = new FinishingPrintingPreSalesContractViewModel()
                {
                    Unit = new UnitViewModel()
                    {
                        Name = "printing"
                    }
                }
            };
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.Run   = "1 run";
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.RunWidth = new List <ProductionOrder_RunWidthViewModel>()
            {
                new ProductionOrder_RunWidthViewModel()
                {
                    Value = -1
                }
            };

            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.RunWidth = new List <ProductionOrder_RunWidthViewModel>()
            {
                new ProductionOrder_RunWidthViewModel()
                {
                    Value = 1
                }
            };
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.StandardTests = new StandardTestsViewModel()
            {
                Id = 1
            };
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.Account = new AccountViewModel();
            response   = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.MaterialOrigin = "a";
            response          = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.HandlingStandard = "e";
            response            = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.ShrinkageStandard = "e";
            response             = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            var data = await DataUtil(facade, dbContext).GetTestData();

            vm.OrderQuantity = 1;
            vm.FinishingPrintingSalesContract.Id = data.SalesContractId;
            vm.Details = new List <ProductionOrder_DetailViewModel>()
            {
                new ProductionOrder_DetailViewModel()
                {
                    Quantity = 1
                }
            };
            vm.LampStandards = new List <ProductionOrder_LampStandardViewModel>();
            response         = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.LampStandards.Add(new ProductionOrder_LampStandardViewModel()
            {
            });
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.LampStandards.FirstOrDefault().Name = "a";
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.Details = new List <ProductionOrder_DetailViewModel>();
            response   = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.Details = new List <ProductionOrder_DetailViewModel>()
            {
                new ProductionOrder_DetailViewModel()
            };
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);
        }
예제 #2
0
        public async void Validate_ViewModel()
        {
            var dbContext = DbContext(GetCurrentMethod());
            var vm        = new ShinProductionOrderViewModel();
            var sp        = GetServiceProviderMock(DbContext(GetCurrentMethod()));

            var facade = new ShinProductionOrderFacade(sp.Object, dbContext);

            sp.Setup(s => s.GetService(typeof(IShinProductionOrder)))
            .Returns(facade);

            var validationContext = new System.ComponentModel.DataAnnotations.ValidationContext(vm, sp.Object, null);
            var response          = vm.Validate(validationContext);

            Assert.NotEmpty(response);

            vm.FinishingPrintingSalesContract = new ShinFinishingPrintingSalesContractViewModel()
            {
                Id = 1,
                CostCalculation = new FinishingPrintingCostCalculationViewModel()
                {
                    PreSalesContract = new FinishingPrintingPreSalesContractViewModel()
                    {
                        Unit = new UnitViewModel()
                        {
                            Name = "printing"
                        }
                    }
                }
            };
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.Run   = "1 run";
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.RunWidth = new List <ProductionOrder_RunWidthViewModel>()
            {
                new ProductionOrder_RunWidthViewModel()
                {
                    Value = -1
                }
            };

            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.RunWidth = new List <ProductionOrder_RunWidthViewModel>()
            {
                new ProductionOrder_RunWidthViewModel()
                {
                    Value = 1
                }
            };
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.StandardTests = new StandardTestsViewModel()
            {
                Id = 1
            };
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.Account = new AccountViewModel();
            response   = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.MaterialOrigin = "a";
            response          = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.HandlingStandard = "e";
            response            = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.ShrinkageStandard = "e";
            response             = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            var data = await DataUtil(facade, dbContext).GetTestData();

            vm.OrderQuantity = 1;
            vm.FinishingPrintingSalesContract.Id = data.SalesContractId;
            vm.Details = new List <ProductionOrder_DetailViewModel>()
            {
                new ProductionOrder_DetailViewModel()
                {
                    Quantity = 1
                }
            };
            vm.LampStandards = new List <ProductionOrder_LampStandardViewModel>();
            response         = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.LampStandards.Add(new ProductionOrder_LampStandardViewModel()
            {
            });
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.LampStandards.FirstOrDefault().Name = "a";
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.Details = new List <ProductionOrder_DetailViewModel>();
            response   = vm.Validate(validationContext);
            Assert.NotEmpty(response);

            vm.Details = new List <ProductionOrder_DetailViewModel>()
            {
                new ProductionOrder_DetailViewModel()
            };
            response = vm.Validate(validationContext);
            Assert.NotEmpty(response);
        }