Exemple #1
0
        public void Should_Success_Validate_Data_Where_DoDate_GreaterThan_ArrivalDate()
        {
            GarmentDeliveryOrderViewModel nullViewModel = new GarmentDeliveryOrderViewModel
            {
                supplier = new SupplierViewModel
                {
                    Id     = 1,
                    Code   = "test",
                    Import = true,
                    Name   = "test"
                }
            };

            Assert.True(nullViewModel.Validate(null).Count() > 0);

            GarmentDeliveryOrderViewModel viewModel = new GarmentDeliveryOrderViewModel
            {
                doDate      = new DateTimeOffset(DateTime.Today).AddDays(7),
                arrivalDate = new DateTimeOffset(DateTime.Today).AddDays(1),
                supplier    = new SupplierViewModel
                {
                    Id     = 1,
                    Code   = "test",
                    Import = true,
                    Name   = "test"
                },
            };

            Assert.True(viewModel.Validate(null).Count() > 0);
        }
Exemple #2
0
        public void Should_Success_Validate_Data()
        {
            GarmentDeliveryOrderViewModel nullViewModel = new GarmentDeliveryOrderViewModel
            {
                supplier = new SupplierViewModel
                {
                    Id     = 1,
                    Code   = "test",
                    Import = true,
                    Name   = "test"
                }
            };

            Assert.True(nullViewModel.Validate(null).Count() > 0);

            GarmentDeliveryOrderViewModel viewModel = new GarmentDeliveryOrderViewModel
            {
                supplier = new SupplierViewModel {
                    Id     = 1,
                    Code   = "test",
                    Import = true,
                    Name   = "test"
                },
            };

            Assert.True(viewModel.Validate(null).Count() > 0);
        }
Exemple #3
0
        public void Should_Success_Validate_Data_Fulfillment_Null()
        {
            GarmentDeliveryOrderViewModel nullViewModel = new GarmentDeliveryOrderViewModel();

            Assert.True(nullViewModel.Validate(null).Count() > 0);

            GarmentDeliveryOrderViewModel viewModel = new GarmentDeliveryOrderViewModel
            {
                supplier      = new SupplierViewModel(),
                customsId     = 1,
                billNo        = "test",
                paymentBill   = "test",
                totalAmount   = 1,
                shipmentType  = "test",
                shipmentNo    = "test",
                paymentMethod = "test",
                paymentType   = "test",
                docurrency    = new CurrencyViewModel(),
                items         = new List <GarmentDeliveryOrderItemViewModel>
                {
                    new GarmentDeliveryOrderItemViewModel
                    {
                        purchaseOrderExternal = new PurchaseOrderExternal {
                            Id = 1, no = "test"
                        },
                        paymentDueDays = 1,
                        currency       = new CurrencyViewModel(),
                        fulfillments   = null
                    }
                }
            };

            Assert.True(viewModel.Validate(null).Count() > 0);
        }
Exemple #4
0
        public void Should_Success_Validate_Data()
        {
            GarmentDeliveryOrderViewModel nullViewModel = new GarmentDeliveryOrderViewModel();

            Assert.True(nullViewModel.Validate(null).Count() > 0);

            GarmentDeliveryOrderViewModel viewModel = new GarmentDeliveryOrderViewModel
            {
                supplier = new SupplierViewModel(),
            };

            Assert.True(viewModel.Validate(null).Count() > 0);
        }
Exemple #5
0
        public async Task Should_Success_Validate_Data_Duplicate()
        {
            GarmentDeliveryOrderFacade facade = new GarmentDeliveryOrderFacade(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            var model = await dataUtil(facade, GetCurrentMethod()).GetTestData();

            GarmentDeliveryOrderViewModel viewModel = new GarmentDeliveryOrderViewModel
            {
                supplier = new SupplierViewModel
                {
                    Id     = 1,
                    Code   = "test",
                    Import = true,
                    Name   = "test"
                },
                incomeTax  = new IncomeTaxViewModel(),
                docurrency = new CurrencyViewModel(),
            };

            viewModel.Id              = model.Id + 1;
            viewModel.doNo            = model.DONo;
            viewModel.supplier.Id     = model.SupplierId;
            viewModel.doDate          = model.DODate;
            viewModel.arrivalDate     = model.ArrivalDate;
            viewModel.docurrency.Id   = (long)model.DOCurrencyId;
            viewModel.docurrency.Code = model.DOCurrencyCode;
            viewModel.incomeTax.Id    = (int)model.IncomeTaxId;
            viewModel.incomeTax.Name  = model.IncomeTaxName;
            viewModel.incomeTax.Rate  = (double)model.IncomeTaxRate;
            viewModel.remark          = model.Remark;
            viewModel.isCorrection    = (bool)model.IsCorrection;
            viewModel.useVat          = (bool)model.UseVat;
            viewModel.useIncomeTax    = (bool)model.UseIncomeTax;


            Mock <IServiceProvider> serviceProvider = new Mock <IServiceProvider>();

            serviceProvider.
            Setup(x => x.GetService(typeof(PurchasingDbContext)))
            .Returns(_dbContext(GetCurrentMethod()));

            System.ComponentModel.DataAnnotations.ValidationContext validationContext = new System.ComponentModel.DataAnnotations.ValidationContext(viewModel, serviceProvider.Object, null);

            var validationResultCreate = viewModel.Validate(validationContext).ToList();

            var errorDuplicateDONo = validationResultCreate.SingleOrDefault(r => r.ErrorMessage.Equals("DoNo is already exist"));

            Assert.NotNull(errorDuplicateDONo);
        }
Exemple #6
0
        public void Should_Success_Validate_Data_Fulfillment_With_Conversion_0()
        {
            GarmentDeliveryOrderViewModel nullViewModel = new GarmentDeliveryOrderViewModel();

            Assert.True(nullViewModel.Validate(null).Count() > 0);

            GarmentDeliveryOrderViewModel viewModel = new GarmentDeliveryOrderViewModel
            {
                supplier      = new SupplierViewModel(),
                customsId     = 1,
                billNo        = "test",
                paymentBill   = "test",
                totalAmount   = 1,
                shipmentType  = "test",
                shipmentNo    = "test",
                paymentMethod = "test",
                paymentType   = "test",
                docurrency    = new CurrencyViewModel(),
                items         = new List <GarmentDeliveryOrderItemViewModel>
                {
                    new GarmentDeliveryOrderItemViewModel
                    {
                        purchaseOrderExternal = new PurchaseOrderExternal {
                            Id = 1, no = "test"
                        },
                        paymentDueDays = 1,
                        currency       = new CurrencyViewModel(),

                        fulfillments = new List <GarmentDeliveryOrderFulfillmentViewModel>
                        {
                            new GarmentDeliveryOrderFulfillmentViewModel
                            {
                                pOId                 = 1,
                                pOItemId             = 1,
                                conversion           = 0,
                                quantityCorrection   = 0,
                                pricePerDealUnit     = 0,
                                priceTotalCorrection = 0,
                            }
                        }
                    }
                }
            };

            Assert.True(viewModel.Validate(null).Count() > 0);
        }
Exemple #7
0
        public void Should_Success_Validate_Data_Item()
        {
            GarmentDeliveryOrderViewModel nullViewModel = new GarmentDeliveryOrderViewModel
            {
                supplier = new SupplierViewModel
                {
                    Id     = 1,
                    Code   = "test",
                    Import = true,
                    Name   = "test"
                }
            };

            Assert.True(nullViewModel.Validate(null).Count() > 0);

            GarmentDeliveryOrderViewModel viewModel = new GarmentDeliveryOrderViewModel
            {
                supplier = new SupplierViewModel
                {
                    Id     = 1,
                    Code   = "test",
                    Import = true,
                    Name   = "test"
                },
                internNo      = "test",
                billNo        = "test",
                paymentBill   = "test",
                totalAmount   = 1,
                shipmentType  = "test",
                shipmentNo    = "test",
                paymentMethod = "test",
                paymentType   = "test",
                docurrency    = new CurrencyViewModel(),
                items         = new List <GarmentDeliveryOrderItemViewModel>
                {
                    new GarmentDeliveryOrderItemViewModel
                    {
                        purchaseOrderExternal = null,
                        paymentDueDays        = 1,
                        currency = new CurrencyViewModel(),

                        fulfillments = new List <GarmentDeliveryOrderFulfillmentViewModel>
                        {
                            new GarmentDeliveryOrderFulfillmentViewModel
                            {
                                pOId             = 1,
                                pOItemId         = 1,
                                conversion       = 2,
                                purchaseOrderUom = new UomViewModel()
                                {
                                    Id   = "1",
                                    Unit = "test"
                                },
                                smallUom = new UomViewModel()
                                {
                                    Id   = "1",
                                    Unit = "test"
                                }
                            }
                        }
                    }
                }
            };

            Assert.True(viewModel.Validate(null).Count() > 0);
        }