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

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

            // Assert
            result.ShouldHaveError();
        }
Esempio n. 2
0
        public async Task <IActionResult> Post([FromBody] PlaceGarmentExpenditureGoodCommand command)
        {
            try
            {
                VerifyUser();

                var order = await Mediator.Send(command);

                return(Ok(order.Identity));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 3
0
        public async Task Handle_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            Guid finStockGuid = Guid.NewGuid();
            PlaceGarmentExpenditureGoodCommandHandler unitUnderTest = CreatePlaceGarmentExpenditureGoodCommandHandler();
            CancellationToken cancellationToken = CancellationToken.None;
            PlaceGarmentExpenditureGoodCommand placeGarmentExpenditureGoodCommand = new PlaceGarmentExpenditureGoodCommand()
            {
                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 = finStockGuid,
                        Description         = "Color",
                        Size     = new SizeValueObject(1, "Size"),
                        isSave   = true,
                        Quantity = 1,
                    }
                },
            };

            _mockExpenditureGoodRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentExpenditureGoodReadModel>().AsQueryable());

            GarmentFinishedGoodStock garmentFinishedGoodStock = new GarmentFinishedGoodStock(finStockGuid,
                                                                                             "no", placeGarmentExpenditureGoodCommand.RONo, "article", new UnitDepartmentId(placeGarmentExpenditureGoodCommand.Unit.Id), placeGarmentExpenditureGoodCommand.Unit.Code, placeGarmentExpenditureGoodCommand.Unit.Name,
                                                                                             new GarmentComodityId(placeGarmentExpenditureGoodCommand.Comodity.Id), placeGarmentExpenditureGoodCommand.Comodity.Code, placeGarmentExpenditureGoodCommand.Comodity.Name,
                                                                                             new SizeId(1), null, new UomId(1), null, 1, 1, 1);


            _mockFinishedGoodStockRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishedGoodStockReadModel>()
            {
                garmentFinishedGoodStock.GetReadModel()
            }.AsQueryable());
            GarmentComodityPrice garmentComodity = new GarmentComodityPrice(
                Guid.NewGuid(),
                true,
                DateTimeOffset.Now,
                new UnitDepartmentId(placeGarmentExpenditureGoodCommand.Unit.Id),
                placeGarmentExpenditureGoodCommand.Unit.Code,
                placeGarmentExpenditureGoodCommand.Unit.Name,
                new GarmentComodityId(placeGarmentExpenditureGoodCommand.Comodity.Id),
                placeGarmentExpenditureGoodCommand.Comodity.Code,
                placeGarmentExpenditureGoodCommand.Comodity.Name,
                1000
                );

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

            _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>()));

            _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(placeGarmentExpenditureGoodCommand, cancellationToken);

            // Assert
            result.Should().NotBeNull();
        }
        public void Place_NotHaveError()
        {
            // Arrange
            Guid id            = Guid.NewGuid();
            var  unitUnderTest = new PlaceGarmentExpenditureGoodCommand()
            {
                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,
                Price             = 1,
                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,
                        isSave        = true,
                        Price         = 1,
                        Quantity      = 1,
                        ReturQuantity = 1,
                        Size          = new SizeValueObject()
                        {
                            Id   = 1,
                            Size = "Size"
                        },
                        StockQuantity = 2,
                        Uom           = new Uom()
                        {
                            Id   = 1,
                            Unit = "Unit"
                        }
                    }
                }
            };

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

            // Assert
            result.ShouldNotHaveError();
        }