public void Place_HaveError()
        {
            // Arrange
            var unitUnderTest = new PlaceGarmentFinishingOutCommand();

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

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

                var order = await Mediator.Send(command);

                return(Ok(order.Identity));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public void Place_HaveError_Date()
        {
            // Arrange
            var validator     = GetValidationRules();
            var unitUnderTest = new PlaceGarmentFinishingOutCommand();

            unitUnderTest.FinishingOutDate = DateTimeOffset.Now.AddDays(-7);
            unitUnderTest.FinishingInDate  = DateTimeOffset.Now;

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

            // Assert
            result.ShouldHaveError();
        }
コード例 #4
0
        public async Task Handle_StateUnderTest_ExpectedBehavior_GudangJadi()
        {
            // Arrange
            Guid finishingInItemGuid = Guid.NewGuid();
            PlaceGarmentFinishingOutCommandHandler unitUnderTest = CreatePlaceGarmentFinishingOutCommandHandler();
            CancellationToken cancellationToken = CancellationToken.None;
            PlaceGarmentFinishingOutCommand placeGarmentFinishingOutCommand = new PlaceGarmentFinishingOutCommand()
            {
                RONo             = "RONo",
                Unit             = new UnitDepartment(1, "UnitCode", "UnitName"),
                UnitTo           = new UnitDepartment(1, "UnitCode2", "UnitName2"),
                Article          = "Article",
                IsDifferentSize  = true,
                FinishingTo      = "GUDANG JADI",
                Comodity         = new GarmentComodity(1, "ComoCode", "ComoName"),
                FinishingOutDate = DateTimeOffset.Now,
                Items            = new List <GarmentFinishingOutItemValueObject>
                {
                    new GarmentFinishingOutItemValueObject
                    {
                        Product           = new Product(1, "ProductCode", "ProductName"),
                        Uom               = new Uom(1, "UomUnit"),
                        FinishingInId     = new Guid(),
                        FinishingInItemId = finishingInItemGuid,
                        Color             = "Color",
                        Size              = new SizeValueObject(1, "Size"),
                        IsSave            = true,
                        Quantity          = 1,
                        DesignColor       = "ColorD",
                        Details           = new List <GarmentFinishingOutDetailValueObject>
                        {
                            new GarmentFinishingOutDetailValueObject
                            {
                                Size     = new SizeValueObject(1, "Size"),
                                Uom      = new Uom(1, "UomUnit"),
                                Quantity = 1
                            }
                        }
                    }
                },
            };

            _mockFinishingOutRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishingOutReadModel>().AsQueryable());
            _mockFinishingInItemRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishingInItemReadModel>
            {
                new GarmentFinishingInItemReadModel(finishingInItemGuid)
            }.AsQueryable());

            _mockFinishedGoodStockRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishedGoodStockReadModel>().AsQueryable());

            GarmentComodityPrice garmentComodity = new GarmentComodityPrice(
                Guid.NewGuid(),
                true,
                DateTimeOffset.Now,
                new UnitDepartmentId(placeGarmentFinishingOutCommand.Unit.Id),
                placeGarmentFinishingOutCommand.Unit.Code,
                placeGarmentFinishingOutCommand.Unit.Name,
                new GarmentComodityId(placeGarmentFinishingOutCommand.Comodity.Id),
                placeGarmentFinishingOutCommand.Comodity.Code,
                placeGarmentFinishingOutCommand.Comodity.Name,
                1000
                );

            _mockComodityPriceRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentComodityPriceReadModel>
            {
                garmentComodity.GetReadModel()
            }.AsQueryable());

            _mockFinishingOutRepository
            .Setup(s => s.Update(It.IsAny <GarmentFinishingOut>()))
            .Returns(Task.FromResult(It.IsAny <GarmentFinishingOut>()));
            _mockFinishingOutItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentFinishingOutItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentFinishingOutItem>()));
            _mockFinishingOutDetailRepository
            .Setup(s => s.Update(It.IsAny <GarmentFinishingOutDetail>()))
            .Returns(Task.FromResult(It.IsAny <GarmentFinishingOutDetail>()));
            _mockFinishingInItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentFinishingInItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentFinishingInItem>()));

            _mockFinishedGoodStockRepository
            .Setup(s => s.Update(It.IsAny <GarmentFinishedGoodStock>()))
            .Returns(Task.FromResult(It.IsAny <GarmentFinishedGoodStock>()));

            _mockFinishedGoodStockHistoryRepository
            .Setup(s => s.Update(It.IsAny <GarmentFinishedGoodStockHistory>()))
            .Returns(Task.FromResult(It.IsAny <GarmentFinishedGoodStockHistory>()));


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

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

            // Assert
            result.Should().NotBeNull();
        }
        public void Place_NotHaveError()
        {
            // Arrange
            Guid id            = Guid.NewGuid();
            var  unitUnderTest = new PlaceGarmentFinishingOutCommand()
            {
                Article  = "Article",
                Comodity = new GarmentComodity()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                FinishingOutDate = DateTimeOffset.Now,
                FinishingInDate  = DateTimeOffset.Now,
                FinishingOutNo   = "FinishingOutNo",
                FinishingTo      = "FinishingTo",
                IsDifferentSize  = true,
                IsSave           = true,
                IsUsed           = true,
                Price            = 1,
                RONo             = "RONo",
                Unit             = new UnitDepartment()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                UnitTo = new UnitDepartment()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                Items = new List <GarmentFinishingOutItemValueObject>()
                {
                    new GarmentFinishingOutItemValueObject()
                    {
                        BasicPrice          = 1,
                        Color               = "Color",
                        DesignColor         = "DesignColor",
                        FinishingInId       = id,
                        FinishingInItemId   = id,
                        FinishingInQuantity = 2,
                        FinishingOutId      = id,
                        Id = id,
                        IsDifferentSize = true,
                        IsSave          = true,
                        Price           = 1,
                        Product         = new Product()
                        {
                            Id   = 1,
                            Code = "Code",
                            Name = "Name"
                        },
                        Quantity          = 1,
                        RemainingQuantity = 2,
                        Size = new SizeValueObject()
                        {
                            Id   = 1,
                            Size = "Size"
                        },
                        TotalQuantity = 1,
                        Uom           = new Uom()
                        {
                            Id   = 1,
                            Unit = "Unit"
                        },
                        Details = new List <GarmentFinishingOutDetailValueObject>()
                        {
                            new GarmentFinishingOutDetailValueObject()
                            {
                                Id = id,
                                FinishingOutItemId = id,
                                Quantity           = 1,
                                Size = new SizeValueObject()
                                {
                                    Id   = 1,
                                    Size = "Size"
                                },
                                Uom = new Uom()
                                {
                                    Id   = 1,
                                    Unit = "Unit"
                                }
                            }
                        }
                    }
                },
            };
            // Action
            var validator = GetValidationRules();
            var result    = validator.TestValidate(unitUnderTest);

            // Assert
            result.ShouldNotHaveError();
        }