示例#1
0
        public void Place_ShouldHaveError()
        {
            // Arrange
            var unitUnderTest = new PlaceGarmentSubconCuttingOutCommand();

            // Action
            var validator = GetValidationRules();
            var result    = validator.TestValidate(unitUnderTest);

            // Assert
            result.ShouldHaveError();
        }
        public async Task <IActionResult> Post([FromBody] PlaceGarmentSubconCuttingOutCommand command)
        {
            try
            {
                VerifyUser();

                var order = await Mediator.Send(command);

                return(Ok(order.Identity));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#3
0
        public void Place_HaveError_Date()
        {
            // Arrange
            var validator     = GetValidationRules();
            var unitUnderTest = new PlaceGarmentSubconCuttingOutCommand();

            unitUnderTest.CuttingOutDate = DateTimeOffset.Now.AddDays(-7);
            unitUnderTest.CuttingInDate  = DateTimeOffset.Now;

            // Action
            var result = validator.TestValidate(unitUnderTest);

            // Assert
            result.ShouldHaveError();
        }
示例#4
0
        public async Task Handle_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            Guid cuttingInDetailGuid = Guid.NewGuid();
            Guid cuttingInGuid       = Guid.NewGuid();
            PlaceGarmentSubconCuttingOutCommandHandler unitUnderTest = CreatePlaceGarmentSubconCuttingOutCommandHandler();
            CancellationToken cancellationToken = CancellationToken.None;
            PlaceGarmentSubconCuttingOutCommand placeGarmentSubconCuttingOutCommand = new PlaceGarmentSubconCuttingOutCommand()
            {
                RONo     = "RONo",
                UnitFrom = new UnitDepartment(1, "UnitCode", "UnitName"),
                Comodity = new GarmentComodity(1, "ComoCode", "ComoName"),

                CuttingOutDate = DateTimeOffset.Now,
                Items          = new List <GarmentSubconCuttingOutItemValueObject>
                {
                    new GarmentSubconCuttingOutItemValueObject
                    {
                        Product           = new Product(1, "ProductCode", "ProductName"),
                        CuttingInDetailId = cuttingInDetailGuid,
                        IsSave            = true,
                        CuttingInId       = cuttingInGuid,
                        Details           = new List <GarmentSubconCuttingOutDetailValueObject>
                        {
                            new GarmentSubconCuttingOutDetailValueObject
                            {
                                CuttingOutUom      = new Uom(2, "PCS"),
                                CuttingOutQuantity = 1,
                                Size   = new SizeValueObject(1, "Size"),
                                Remark = "asad"
                            }
                        }
                    }
                },
            };

            _mockSubconCuttingOutRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentCuttingOutReadModel>().AsQueryable());
            _mockCuttingInDetailRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentCuttingInDetailReadModel>
            {
                new GarmentCuttingInDetailReadModel(cuttingInDetailGuid)
            }.AsQueryable());
            _mockSubconCuttingRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentSubconCuttingReadModel>
            {
                new GarmentSubconCuttingReadModel(Guid.NewGuid())
            }.AsQueryable());

            _mockSubconCuttingOutRepository
            .Setup(s => s.Update(It.IsAny <GarmentSubconCuttingOut>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSubconCuttingOut>()));
            _mockSubconCuttingOutItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentSubconCuttingOutItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSubconCuttingOutItem>()));
            _mockSubconCuttingOutDetailRepository
            .Setup(s => s.Update(It.IsAny <GarmentSubconCuttingOutDetail>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSubconCuttingOutDetail>()));
            _mockCuttingInDetailRepository
            .Setup(s => s.Update(It.IsAny <GarmentCuttingInDetail>()))
            .Returns(Task.FromResult(It.IsAny <GarmentCuttingInDetail>()));
            _mockSubconCuttingRepository
            .Setup(s => s.Update(It.IsAny <GarmentSubconCutting>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSubconCutting>()));
            _mockSubconCuttingRelationRepository
            .Setup(s => s.Update(It.IsAny <GarmentSubconCuttingRelation>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSubconCuttingRelation>()));

            _MockStorage
            .Setup(x => x.Save())
            .Verifiable();

            // Act
            var result = await unitUnderTest.Handle(placeGarmentSubconCuttingOutCommand, cancellationToken);

            // Assert
            result.Should().NotBeNull();
        }
示例#5
0
        public void Place_ShouldNotHaveError()
        {
            // Arrange
            Guid id            = Guid.NewGuid();
            var  unitUnderTest = new PlaceGarmentSubconCuttingOutCommand()
            {
                Article  = "Article",
                Price    = 1,
                RONo     = "RONo",
                Comodity = new GarmentComodity()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                Unit = new UnitDepartment()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                CutOutNo                = "CutOutNo",
                CuttingOutDate          = DateTimeOffset.Now,
                CuttingInDate           = DateTimeOffset.Now,
                CuttingOutType          = "CuttingOutType",
                EPOId                   = 1,
                EPOItemId               = 1,
                PlanPORemainingQuantity = 1,
                POSerialNumber          = "POSerialNumber",
                TotalQty                = 1,
                UnitFrom                = new UnitDepartment()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                Items = new List <GarmentSubconCuttingOutItemValueObject>()
                {
                    new GarmentSubconCuttingOutItemValueObject()
                    {
                        CutOutId          = id,
                        CuttingInDetailId = id,
                        CuttingInId       = id,
                        DesignColor       = "DesignColor",
                        Id      = id,
                        IsSave  = true,
                        Product = new Product()
                        {
                            Id   = 1,
                            Code = "Code",
                            Name = "Name"
                        },
                        TotalCuttingOut                     = 1,
                        TotalCuttingOutQuantity             = 1,
                        TotalRemainingQuantityCuttingInItem = 2,
                        Details = new List <GarmentSubconCuttingOutDetailValueObject>()
                        {
                            new GarmentSubconCuttingOutDetailValueObject()
                            {
                                Color              = "Color",
                                BasicPrice         = 1,
                                CutOutItemId       = id,
                                CuttingOutQuantity = 1,
                                CuttingOutUom      = new Uom()
                                {
                                    Id   = 1,
                                    Unit = "Unit"
                                },
                                Id                = id,
                                Price             = 1,
                                RemainingQuantity = 2,
                                Remark            = "Remark",
                                Size              = new SizeValueObject()
                                {
                                    Id   = 1,
                                    Size = "Size"
                                }
                            }
                        }
                    }
                }
            };

            // Action
            var validator = GetValidationRules();
            var result    = validator.TestValidate(unitUnderTest);

            // Assert
            result.ShouldNotHaveError();
        }