Beispiel #1
0
        public async Task <IActionResult> Put(string id, [FromBody] UpdateGarmentExpenditureGoodCommand command)
        {
            Guid guid = Guid.Parse(id);

            command.SetIdentity(guid);

            VerifyUser();

            var order = await Mediator.Send(command);

            return(Ok(order.Identity));
        }
        public void Place_HaveError()
        {
            // Arrange
            var unitUnderTest = new UpdateGarmentExpenditureGoodCommand();

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

            // Assert
            result.ShouldHaveError();
        }
Beispiel #3
0
        public async Task Handle_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            Guid ExpenditureGoodGuid     = Guid.NewGuid();
            Guid ExpenditureGoodItemGuid = Guid.NewGuid();
            UpdateGarmentExpenditureGoodCommandHandler unitUnderTest = CreateUpdateGarmentExpenditureGoodCommandHandler();
            CancellationToken cancellationToken = CancellationToken.None;
            UpdateGarmentExpenditureGoodCommand UpdateGarmentExpenditureGoodCommand = new UpdateGarmentExpenditureGoodCommand()
            {
                RONo            = "RONo",
                Unit            = new UnitDepartment(1, "UnitCode", "UnitName"),
                Article         = "Article",
                Comodity        = new GarmentComodity(1, "ComoCode", "ComoName"),
                Buyer           = new Buyer(1, "buyerCode", "buyerName"),
                ExpenditureDate = DateTimeOffset.Now,
                Items           = new List <GarmentExpenditureGoodItemValueObject>
                {
                    new GarmentExpenditureGoodItemValueObject
                    {
                        Uom = new Uom(1, "UomUnit"),
                        FinishedGoodStockId = new Guid(),
                        Size     = new SizeValueObject(1, "Size"),
                        isSave   = true,
                        Quantity = 1,
                    }
                },
            };

            UpdateGarmentExpenditureGoodCommand.SetIdentity(ExpenditureGoodGuid);

            _mockExpenditureGoodRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentExpenditureGoodReadModel>()
            {
                new GarmentExpenditureGoodReadModel(ExpenditureGoodGuid)
            }.AsQueryable());
            _mockExpenditureGoodItemRepository
            .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentExpenditureGoodItemReadModel, bool> > >()))
            .Returns(new List <GarmentExpenditureGoodItem>()
            {
                new GarmentExpenditureGoodItem(ExpenditureGoodItemGuid, ExpenditureGoodGuid, Guid.Empty, new SizeId(1), null, 1, 0, new UomId(1), null, null, 1, 1)
            });

            _mockExpenditureGoodRepository
            .Setup(s => s.Update(It.IsAny <GarmentExpenditureGood>()))
            .Returns(Task.FromResult(It.IsAny <GarmentExpenditureGood>()));
            _mockExpenditureGoodItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentExpenditureGoodItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentExpenditureGoodItem>()));


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

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

            // Assert
            result.Should().NotBeNull();
        }
        public void Place_NotHaveError()
        {
            // Arrange
            Guid id            = Guid.NewGuid();
            var  unitUnderTest = new UpdateGarmentExpenditureGoodCommand()
            {
                Article = "Article",
                Buyer   = new Buyer()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                Carton   = 1,
                Comodity = new GarmentComodity()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                ContractNo        = "ContractNo",
                Description       = "Description",
                ExpenditureDate   = DateTimeOffset.Now,
                ExpenditureGoodNo = "ExpenditureGoodNo",
                ExpenditureType   = "ExpenditureType",
                Invoice           = "Invoice",
                IsReceived        = true,
                RONo = "RONo",
                Unit = new UnitDepartment()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                Items = new List <GarmentExpenditureGoodItemValueObject>()
                {
                    new GarmentExpenditureGoodItemValueObject()
                    {
                        BasicPrice          = 1,
                        Description         = "Description",
                        ExpenditureGoodId   = id,
                        FinishedGoodStockId = id,
                        Id            = id,
                        isSave        = true,
                        Price         = 1,
                        Quantity      = 1,
                        ReturQuantity = 1,
                        Size          = new SizeValueObject()
                        {
                            Id = 1,
                        },
                        StockQuantity = 2,
                        Uom           = new Uom()
                        {
                            Id   = 1,
                            Unit = "Unit"
                        }
                    }
                }
            };

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

            // Assert
            result.ShouldNotHaveError();
        }