public void should_success_instantiate()
        {
            Guid id = Guid.NewGuid();
            GarmentExpenditureGood item = new GarmentExpenditureGood(new GarmentExpenditureGoodReadModel(id));

            item.SetCarton(1);
            item.SetInvoice("Invoice");
            item.Modify();
            Assert.NotNull(item);
        }
Пример #2
0
 public GarmentExpenditureGoodDto(GarmentExpenditureGood garmentExpenditureGood)
 {
     Id = garmentExpenditureGood.Identity;
     ExpenditureGoodNo = garmentExpenditureGood.ExpenditureGoodNo;
     RONo            = garmentExpenditureGood.RONo;
     Article         = garmentExpenditureGood.Article;
     Unit            = new UnitDepartment(garmentExpenditureGood.UnitId.Value, garmentExpenditureGood.UnitCode, garmentExpenditureGood.UnitName);
     ExpenditureDate = garmentExpenditureGood.ExpenditureDate;
     ExpenditureType = garmentExpenditureGood.ExpenditureType;
     Comodity        = new GarmentComodity(garmentExpenditureGood.ComodityId.Value, garmentExpenditureGood.ComodityCode, garmentExpenditureGood.ComodityName);
     Buyer           = new Buyer(garmentExpenditureGood.BuyerId.Value, garmentExpenditureGood.BuyerCode, garmentExpenditureGood.BuyerName);
     Invoice         = garmentExpenditureGood.Invoice;
     ContractNo      = garmentExpenditureGood.ContractNo;
     Carton          = garmentExpenditureGood.Carton;
     Description     = garmentExpenditureGood.Description;
     IsReceived      = garmentExpenditureGood.IsReceived;
     Items           = new List <GarmentExpenditureGoodItemDto>();
 }
Пример #3
0
        public async Task Handle_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            Guid finStockGuid   = Guid.NewGuid();
            Guid exGoodGuid     = Guid.NewGuid();
            Guid exGoodItemGuid = Guid.NewGuid();
            PlaceGarmentExpenditureGoodReturnCommandHandler unitUnderTest = CreatePlaceGarmentExpenditureGoodReturnCommandHandler();
            CancellationToken cancellationToken = CancellationToken.None;
            PlaceGarmentExpenditureGoodReturnCommand placeGarmentExpenditureGoodReturnCommand = new PlaceGarmentExpenditureGoodReturnCommand()
            {
                RONo      = "RONo",
                Unit      = new UnitDepartment(1, "UnitCode", "UnitName"),
                Article   = "Article",
                Comodity  = new GarmentComodity(1, "ComoCode", "ComoName"),
                Buyer     = new Buyer(1, "buyerCode", "buyerName"),
                ReturDate = DateTimeOffset.Now,
                Items     = new List <GarmentExpenditureGoodReturnItemValueObject>
                {
                    new GarmentExpenditureGoodReturnItemValueObject
                    {
                        Uom = new Uom(1, "UomUnit"),
                        FinishedGoodStockId   = finStockGuid,
                        ExpenditureGoodId     = exGoodGuid,
                        ExpenditureGoodItemId = exGoodItemGuid,
                        Description           = "Color",
                        Size     = new SizeValueObject(1, "Size"),
                        isSave   = true,
                        Quantity = 1,
                    }
                },
            };

            _mockExpenditureGoodReturnRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentExpenditureGoodReturnReadModel>().AsQueryable());
            _mockFinishedGoodStockRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishedGoodStockReadModel>()
            {
                new GarmentFinishedGoodStockReadModel(finStockGuid)
            }.AsQueryable());

            GarmentExpenditureGood garmentExpenditureGood = new GarmentExpenditureGood(exGoodGuid, "no", null,
                                                                                       new UnitDepartmentId(placeGarmentExpenditureGoodReturnCommand.Unit.Id), null, null, placeGarmentExpenditureGoodReturnCommand.RONo, null, new GarmentComodityId(1),
                                                                                       null, null, new BuyerId(1), null, null, DateTimeOffset.Now, null, null, 0, null, false);

            GarmentExpenditureGoodItem garmentExpenditureGoodItem = new GarmentExpenditureGoodItem(
                exGoodItemGuid, exGoodGuid, finStockGuid, new SizeId(1), null, 1, 0, new UomId(1), null, "Color", 1, 1);

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

            _mockExpenditureGoodItemRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentExpenditureGoodItemReadModel>
            {
                garmentExpenditureGoodItem.GetReadModel()
            }.AsQueryable());



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

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

            _mockExpenditureGoodReturnRepository
            .Setup(s => s.Update(It.IsAny <GarmentExpenditureGoodReturn>()))
            .Returns(Task.FromResult(It.IsAny <GarmentExpenditureGoodReturn>()));
            _mockExpenditureGoodReturnItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentExpenditureGoodReturnItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentExpenditureGoodReturnItem>()));

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

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

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

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

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

            // Assert
            result.Should().NotBeNull();
        }
Пример #4
0
        public async Task Handle_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            Guid finStockGuid   = Guid.NewGuid();
            Guid exGoodGuid     = Guid.NewGuid();
            Guid exGoodItemGuid = Guid.NewGuid();
            Guid returId        = Guid.NewGuid();
            Guid returItemId    = Guid.NewGuid();
            RemoveGarmentExpenditureGoodCommandHandler unitUnderTest = CreateRemoveGarmentExpenditureGoodCommandHandler();
            CancellationToken cancellationToken = CancellationToken.None;
            RemoveGarmentExpenditureGoodCommand RemoveGarmentFinishingOutCommand = new RemoveGarmentExpenditureGoodCommand(exGoodGuid);

            GarmentExpenditureGood expenditureGood = new GarmentExpenditureGood(
                exGoodGuid, "no", "export", new UnitDepartmentId(1), "uCode", "Uname", "roNo", "art", new GarmentComodityId(1),
                "cCode", "cName", new BuyerId(1), "nam", "bCode", DateTimeOffset.Now, "inv", "con", 0, null, false);

            GarmentFinishedGoodStock garmentFinishedGoodStock = new GarmentFinishedGoodStock(finStockGuid,
                                                                                             "no", "ro", "article", expenditureGood.UnitId, expenditureGood.UnitCode, expenditureGood.UnitName,
                                                                                             expenditureGood.ComodityId, expenditureGood.ComodityCode, expenditureGood.ComodityName,
                                                                                             new SizeId(1), null, new UomId(1), null, 1, 1, 1);

            GarmentFinishedGoodStockHistory garmentFinishedGoodStockHistory = new GarmentFinishedGoodStockHistory(Guid.NewGuid(), garmentFinishedGoodStock.Identity,
                                                                                                                  Guid.Empty, Guid.Empty, exGoodGuid, exGoodItemGuid, Guid.Empty, Guid.Empty, returId, returItemId, null, "ro", "article", expenditureGood.UnitId, expenditureGood.UnitCode, expenditureGood.UnitName,
                                                                                                                  expenditureGood.ComodityId, expenditureGood.ComodityCode, expenditureGood.ComodityName,
                                                                                                                  new SizeId(1), null, new UomId(1), null, 1, 1, 1);

            _mockFinishedGoodStockRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishedGoodStockReadModel>
            {
                garmentFinishedGoodStock.GetReadModel()
            }.AsQueryable());
            _mockExpenditureGoodRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentExpenditureGoodReadModel>
            {
                expenditureGood.GetReadModel()
            }.AsQueryable());

            _mockExpenditureGoodItemRepository
            .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentExpenditureGoodItemReadModel, bool> > >()))
            .Returns(new List <GarmentExpenditureGoodItem>()
            {
                new GarmentExpenditureGoodItem(exGoodItemGuid, exGoodGuid, finStockGuid, new SizeId(1), null, 1, 0, new UomId(1), null, null, 1, 1)
            });

            //_mockExpenditureGoodItemRepository
            //    .Setup(s => s.Query)
            //    .Returns(new List<GarmentExpenditureGoodItemReadModel>
            //    {
            //        new GarmentExpenditureGoodItemReadModel(exGoodItemGuid)
            //    }.AsQueryable());

            _mockFinishedGoodStockHistoryRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishedGoodStockHistoryReadModel>
            {
                garmentFinishedGoodStockHistory.GetReadModel()
            }.AsQueryable());

            GarmentComodityPrice garmentComodity = new GarmentComodityPrice(
                Guid.NewGuid(),
                true,
                DateTimeOffset.Now,
                new UnitDepartmentId(expenditureGood.UnitId.Value),
                expenditureGood.UnitCode,
                expenditureGood.UnitName,
                new GarmentComodityId(expenditureGood.ComodityId.Value),
                expenditureGood.ComodityCode,
                expenditureGood.ComodityName,
                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(RemoveGarmentFinishingOutCommand, cancellationToken);

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