예제 #1
0
        public async Task <IActionResult> Post([FromBody] PlaceGarmentSubconFinishingInCommand command)
        {
            try
            {
                VerifyUser();

                var order = await Mediator.Send(command);

                return(Ok(order.Identity));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public void Place_NotHaveError()
        {
            // Arrange
            var unitUnderTest = new PlaceGarmentSubconFinishingInCommand();

            unitUnderTest.Unit            = new UnitDepartment(1, "Unit", "Unit");
            unitUnderTest.FinishingInDate = DateTimeOffset.Now.AddDays(-1);
            unitUnderTest.Comodity        = new GarmentComodity(1, "Comodity", "Comodity");
            unitUnderTest.Supplier        = new { };
            unitUnderTest.DOId            = 1;
            unitUnderTest.DONo            = "DONo";
            unitUnderTest.RONo            = "RONo";
            unitUnderTest.Article         = "Article";
            unitUnderTest.TotalQuantity   = 0;
            unitUnderTest.Items           = new List <GarmentSubconFinishingInItemValueObject>
            {
                new GarmentSubconFinishingInItemValueObject
                {
                    IsSave   = true,
                    Quantity = 10,
                    Product  = new Product(1, "Product", "Product"),
                    Size     = new SizeValueObject(1, "Size")
                }
            };

            _mockGarmentFinishingInRepository.Setup(s => s.Query)
            .Returns(new List <GarmentFinishingInReadModel>
            {
                new GarmentFinishingIn(Guid.Empty, null, null, new UnitDepartmentId(1), null, null, "Not" + unitUnderTest.RONo, null, new UnitDepartmentId(1), null, null, DateTimeOffset.Now, new GarmentComodityId(1), null, null, unitUnderTest.DOId + 1, "Not" + unitUnderTest.DONo).GetReadModel()
            }.AsQueryable());

            var validator = GetValidationRules();

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

            // Assert
            result.ShouldNotHaveError();
        }
        public void Place_HaveError()
        {
            // Arrange
            var unitUnderTest = new PlaceGarmentSubconFinishingInCommand();

            unitUnderTest.DOId = 1;
            unitUnderTest.RONo = "RONo";

            _mockGarmentFinishingInRepository.Setup(s => s.Query)
            .Returns(new List <GarmentFinishingInReadModel>
            {
                new GarmentFinishingIn(Guid.Empty, null, null, new UnitDepartmentId(1), null, null, unitUnderTest.RONo, null, new UnitDepartmentId(1), null, null, DateTimeOffset.Now, new GarmentComodityId(1), null, null, unitUnderTest.DOId, null).GetReadModel()
            }.AsQueryable());

            var validator = GetValidationRules();

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

            // Assert
            result.ShouldHaveError();
        }
예제 #4
0
        public async Task Handle_Place_Success()
        {
            // Arrange
            Guid subconCuttingId = Guid.NewGuid();
            Guid sewingOutGuid   = Guid.NewGuid();
            PlaceGarmentSubconFinishingInCommandHandler unitUnderTest = CreatePlaceGarmentSubconFinishingInCommandHandler();
            CancellationToken cancellationToken = CancellationToken.None;
            PlaceGarmentSubconFinishingInCommand placeGarmentSubconFinishingInCommand = new PlaceGarmentSubconFinishingInCommand()
            {
                RONo            = "RONo",
                Unit            = new UnitDepartment(1, "UnitCode", "UnitName"),
                FinishingInDate = DateTimeOffset.Now,
                Article         = "Article",
                Comodity        = new GarmentComodity(1, "ComoCode", "ComoName"),
                Items           = new List <GarmentSubconFinishingInItemValueObject>
                {
                    new GarmentSubconFinishingInItemValueObject
                    {
                        IsSave            = true,
                        SubconCuttingId   = subconCuttingId,
                        Size              = new SizeValueObject(1, "Size"),
                        Quantity          = 1,
                        RemainingQuantity = 1,
                        Product           = new Product(1, "ProdCode", "ProdName"),
                        Uom = new Uom(1, "Uom"),
                    },
                },
            };

            _mockFinishingInRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishingInReadModel>().AsQueryable());
            _mockSubconCuttingRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentSubconCuttingReadModel>
            {
                new GarmentSubconCuttingReadModel(subconCuttingId)
            }.AsQueryable());
            _mockIComodityPriceRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentComodityPriceReadModel>
            {
                new GarmentComodityPriceReadModel(Guid.NewGuid())
            }.AsQueryable());

            _mockFinishingInRepository
            .Setup(s => s.Update(It.IsAny <GarmentFinishingIn>()))
            .Returns(Task.FromResult(It.IsAny <GarmentFinishingIn>()));
            _mockFinishingInItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentFinishingInItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentFinishingInItem>()));
            _mockSubconCuttingRepository
            .Setup(s => s.Update(It.IsAny <GarmentSubconCutting>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSubconCutting>()));

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

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

            // Assert
            result.Should().NotBeNull();
        }