示例#1
0
        public async Task Handle_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            Guid id = Guid.NewGuid();
            UpdateGarmentComodityPriceCommandHandler unitUnderTest = CreateUpdateGarmentComodityPriceCommandHandler();
            CancellationToken cancellationToken       = CancellationToken.None;
            UpdateGarmentComodityPriceCommand request = new UpdateGarmentComodityPriceCommand()
            {
                Unit = new UnitDepartment()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                Date  = DateTimeOffset.Now,
                Items = new List <GarmentComodityPriceItemValueObject>()
                {
                    new GarmentComodityPriceItemValueObject()
                    {
                        Id       = id,
                        IsValid  = true,
                        Comodity = new GarmentComodity()
                        {
                            Id   = 1,
                            Code = "Code",
                            Name = "Name"
                        },
                        Date     = DateTimeOffset.Now,
                        NewPrice = 2,
                        Price    = 2,
                        Unit     = new UnitDepartment()
                        {
                            Id   = 1,
                            Code = "Code",
                            Name = "Name"
                        }
                    }
                }
            };

            request.SetIdentity(id);

            GarmentComodityPrice garmentComodityPrice = new GarmentComodityPrice(id, true, DateTimeOffset.Now, new UnitDepartmentId(1), "unitCode", "unitName", new GarmentComodityId(1), "comodityCode", "comodityName", 1);

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

            _mockComodityPriceRepository
            .Setup(s => s.Update(It.IsAny <GarmentComodityPrice>()))
            .Returns(Task.FromResult(It.IsAny <GarmentComodityPrice>()));

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

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

            // Assert
            result.Should().NotBeNull();
            result.Count().Should().BeGreaterThan(0);
        }
示例#2
0
        public async Task Handle_StateUnderTest_ExpectedBehavior_LOADING()
        {
            // Arrange
            Guid adjustmentGuid   = Guid.NewGuid();
            Guid sewingDOItemGuid = Guid.NewGuid();
            Guid sewingInItemGuid = Guid.NewGuid();
            Guid sewingDOGuid     = Guid.NewGuid();
            RemoveGarmentAdjustmentCommandHandler unitUnderTest = CreateRemoveGarmentAdjustmentCommandHandler();
            CancellationToken cancellationToken = CancellationToken.None;
            RemoveGarmentAdjustmentCommand RemoveGarmentAdjustmentCommand = new RemoveGarmentAdjustmentCommand(adjustmentGuid);

            GarmentAdjustment garmentAdjustment = new GarmentAdjustment(
                adjustmentGuid, null, "LOADING", "roNo", null, new UnitDepartmentId(1), null, null, DateTimeOffset.Now,
                new GarmentComodityId(1), null, null, null);

            _mockAdjustmentRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentAdjustmentReadModel>()
            {
                garmentAdjustment.GetReadModel()
            }.AsQueryable());

            _mockAdjustmentItemRepository
            .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentAdjustmentItemReadModel, bool> > >()))
            .Returns(new List <GarmentAdjustmentItem>()
            {
                new GarmentAdjustmentItem(Guid.Empty, Guid.Empty, sewingDOItemGuid, sewingInItemGuid, Guid.Empty, Guid.Empty, new SizeId(1), null, new ProductId(1), null, null, null, 1, 10, new UomId(1), null, null, 1)
            });


            _mockSewingDOItemRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentSewingDOItemReadModel>
            {
                new GarmentSewingDOItemReadModel(sewingDOItemGuid)
            }.AsQueryable());

            GarmentComodityPrice garmentComodity = new GarmentComodityPrice(
                Guid.NewGuid(),
                true,
                DateTimeOffset.Now,
                new UnitDepartmentId(garmentAdjustment.UnitId.Value),
                garmentAdjustment.UnitCode,
                garmentAdjustment.UnitName,
                new GarmentComodityId(garmentAdjustment.ComodityId.Value),
                garmentAdjustment.ComodityCode,
                garmentAdjustment.ComodityName,
                1000
                );

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

            _mockAdjustmentRepository
            .Setup(s => s.Update(It.IsAny <GarmentAdjustment>()))
            .Returns(Task.FromResult(It.IsAny <GarmentAdjustment>()));
            _mockAdjustmentItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentAdjustmentItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentAdjustmentItem>()));
            _mockSewingDOItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentSewingDOItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSewingDOItem>()));

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

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

            // Assert
            result.Should().NotBeNull();
        }
示例#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();
        }
示例#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 async Task Handle_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            Guid sewingInItemGuid = Guid.NewGuid();
            Guid sewingOutGuid    = Guid.NewGuid();
            Guid sewingInId       = Guid.NewGuid();
            UpdateGarmentSewingOutCommandHandler unitUnderTest          = CreateUpdateGarmentSewingOutCommandHandler();
            CancellationToken             cancellationToken             = CancellationToken.None;
            UpdateGarmentSewingOutCommand UpdateGarmentSewingOutCommand = new UpdateGarmentSewingOutCommand()
            {
                RONo            = "RONo",
                Unit            = new UnitDepartment(1, "UnitCode", "UnitName"),
                UnitTo          = new UnitDepartment(2, "UnitCode2", "UnitName2"),
                Article         = "Article",
                IsDifferentSize = true,
                Buyer           = new Buyer(1, "BuyerCode", "BuyerName"),
                SewingTo        = "FINISHING",
                Comodity        = new GarmentComodity(1, "ComoCode", "ComoName"),
                SewingOutDate   = DateTimeOffset.Now,
                Items           = new List <GarmentSewingOutItemValueObject>
                {
                    new GarmentSewingOutItemValueObject
                    {
                        Product        = new Product(1, "ProductCode", "ProductName"),
                        Uom            = new Uom(1, "UomUnit"),
                        SewingInId     = sewingInId,
                        SewingInItemId = sewingInItemGuid,
                        Color          = "Color",
                        Size           = new SizeValueObject(1, "Size"),
                        IsSave         = true,
                        Quantity       = 1,
                        DesignColor    = "ColorD",
                        Details        = new List <GarmentSewingOutDetailValueObject>
                        {
                            new GarmentSewingOutDetailValueObject
                            {
                                Size     = new SizeValueObject(1, "Size"),
                                Uom      = new Uom(1, "UomUnit"),
                                Quantity = 1
                            }
                        }
                    }
                },
            };

            UpdateGarmentSewingOutCommand.SetIdentity(sewingOutGuid);

            _mockSewingOutRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentSewingOutReadModel>()
            {
                new GarmentSewingOutReadModel(sewingOutGuid)
            }.AsQueryable());
            _mockSewingOutItemRepository
            .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentSewingOutItemReadModel, bool> > >()))
            .Returns(new List <GarmentSewingOutItem>()
            {
                new GarmentSewingOutItem(Guid.Empty, sewingOutGuid, Guid.Empty, sewingInItemGuid, new ProductId(1), null, null, null, new SizeId(1), null, 1, new UomId(1), null, null, 1, 1, 1)
            });
            _mockSewingOutDetailRepository
            .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentSewingOutDetailReadModel, bool> > >()))
            .Returns(new List <GarmentSewingOutDetail>()
            {
                new GarmentSewingOutDetail(Guid.Empty, Guid.Empty, new SizeId(1), null, 1, new UomId(1), null)
            });

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

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

            _mockSewingInItemRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentSewingInItemReadModel>
            {
                new GarmentSewingInItemReadModel(sewingInItemGuid)
            }.AsQueryable());

            _mockSewingOutRepository
            .Setup(s => s.Update(It.IsAny <GarmentSewingOut>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSewingOut>()));
            _mockSewingOutItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentSewingOutItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSewingOutItem>()));
            _mockSewingOutDetailRepository
            .Setup(s => s.Update(It.IsAny <GarmentSewingOutDetail>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSewingOutDetail>()));
            _mockSewingInItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentSewingInItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSewingInItem>()));

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

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

            // Assert
            result.Should().NotBeNull();
        }
示例#6
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();
        }
示例#7
0
        public async Task Handle_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            Guid cuttingInDetailGuid = Guid.NewGuid();
            Guid cuttingInGuid       = Guid.NewGuid();
            PlaceGarmentCuttingOutCommandHandler unitUnderTest          = CreatePlaceGarmentCuttingOutCommandHandler();
            CancellationToken             cancellationToken             = CancellationToken.None;
            PlaceGarmentCuttingOutCommand placeGarmentCuttingOutCommand = new PlaceGarmentCuttingOutCommand()
            {
                RONo           = "RONo",
                UnitFrom       = new UnitDepartment(1, "UnitCode", "UnitName"),
                Comodity       = new GarmentComodity(1, "ComoCode", "ComoName"),
                Unit           = new UnitDepartment(1, "UnitCode", "UnitName"),
                CuttingOutDate = DateTimeOffset.Now,
                Items          = new List <GarmentCuttingOutItemValueObject>
                {
                    new GarmentCuttingOutItemValueObject
                    {
                        Product           = new Product(1, "ProductCode", "ProductName"),
                        CuttingInDetailId = cuttingInDetailGuid,
                        IsSave            = true,
                        CuttingInId       = cuttingInGuid,
                        Details           = new List <GarmentCuttingOutDetailValueObject>
                        {
                            new GarmentCuttingOutDetailValueObject
                            {
                                CuttingOutUom      = new Uom(2, "PCS"),
                                CuttingOutQuantity = 1,
                                Size  = new SizeValueObject(1, "Size"),
                                Color = "kajsj"
                            }
                        }
                    }
                },
            };

            _mockCuttingOutRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentCuttingOutReadModel>().AsQueryable());

            _mockSewingDORepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentSewingDOReadModel>().AsQueryable());

            _mockCuttingInDetailRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentCuttingInDetailReadModel>
            {
                new GarmentCuttingInDetailReadModel(cuttingInDetailGuid)
            }.AsQueryable());

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

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

            _mockCuttingOutRepository
            .Setup(s => s.Update(It.IsAny <GarmentCuttingOut>()))
            .Returns(Task.FromResult(It.IsAny <GarmentCuttingOut>()));
            _mockCuttingOutItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentCuttingOutItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentCuttingOutItem>()));
            _mockCuttingOutDetailRepository
            .Setup(s => s.Update(It.IsAny <GarmentCuttingOutDetail>()))
            .Returns(Task.FromResult(It.IsAny <GarmentCuttingOutDetail>()));
            _mockCuttingInDetailRepository
            .Setup(s => s.Update(It.IsAny <GarmentCuttingInDetail>()))
            .Returns(Task.FromResult(It.IsAny <GarmentCuttingInDetail>()));

            _mockSewingDORepository
            .Setup(s => s.Update(It.IsAny <GarmentSewingDO>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSewingDO>()));
            _mockSewingDOItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentSewingDOItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSewingDOItem>()));

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

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

            // Assert
            result.Should().NotBeNull();
        }
        public async Task Handle_StateUnderTest_ExpectedBehavior_BARANGJADI()
        {
            // Arrange
            Guid finishedGoodStockId = Guid.NewGuid();
            Guid sewingDOGuid        = Guid.NewGuid();
            PlaceGarmentAdjustmentCommandHandler unitUnderTest          = CreatePlaceGarmentAdjustmentCommandHandler();
            CancellationToken             cancellationToken             = CancellationToken.None;
            PlaceGarmentAdjustmentCommand placeGarmentAdjustmentCommand = new PlaceGarmentAdjustmentCommand()
            {
                RONo           = "RONo",
                Unit           = new UnitDepartment(1, "UnitCode", "UnitName"),
                AdjustmentType = "BARANG JADI",
                AdjustmentDate = DateTimeOffset.Now,
                Article        = "Article",
                Comodity       = new GarmentComodity(1, "ComoCode", "ComoName"),
                Items          = new List <GarmentAdjustmentItemValueObject>
                {
                    new GarmentAdjustmentItemValueObject
                    {
                        IsSave              = true,
                        FinishingInItemId   = Guid.Empty,
                        FinishedGoodStockId = finishedGoodStockId,
                        Size              = new SizeValueObject(1, "Size"),
                        Quantity          = 1,
                        RemainingQuantity = 2,
                        Product           = new Product(1, "ProdCode", "ProdName"),
                        Uom   = new Uom(1, "Uom"),
                        Color = "www"
                    }
                },
            };

            _mockFinishedGoodStockRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishedGoodStockReadModel>
            {
                new GarmentFinishedGoodStock(finishedGoodStockId, "", "RONo", "article", new UnitDepartmentId(1), "code", "name", new GarmentComodityId(1), "", "", new SizeId(1), "", new UomId(1), "", 10, 100, 100).GetReadModel()
            }.AsQueryable());

            _mockAdjustmentRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentAdjustmentReadModel>().AsQueryable());

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

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

            _mockAdjustmentRepository
            .Setup(s => s.Update(It.IsAny <GarmentAdjustment>()))
            .Returns(Task.FromResult(It.IsAny <GarmentAdjustment>()));
            _mockAdjustmentItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentAdjustmentItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentAdjustmentItem>()));
            _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(placeGarmentAdjustmentCommand, cancellationToken);

            // Assert
            result.Should().NotBeNull();
        }
示例#9
0
        public async Task Handle_StateUnderTest_ExpectedBehavior_GUDANGJADI()
        {
            // Arrange
            Guid finishingInItemGuid    = Guid.NewGuid();
            Guid finishingOutGuid       = Guid.NewGuid();
            Guid finishingOutItemGuid   = Guid.NewGuid();
            Guid finishingOutDetailGuid = Guid.NewGuid();
            RemoveGarmentFinishingOutCommandHandler unitUnderTest = CreateRemoveGarmentFinishingOutCommandHandler();
            CancellationToken cancellationToken = CancellationToken.None;
            RemoveGarmentFinishingOutCommand RemoveGarmentFinishingOutCommand = new RemoveGarmentFinishingOutCommand(finishingOutGuid);

            GarmentFinishingOut garmentFinishingOut = new GarmentFinishingOut(
                finishingOutGuid,
                "no", new UnitDepartmentId(1), "uCode", "Uname", "GUDANG JADI", DateTimeOffset.Now, "ro", "article",
                new UnitDepartmentId(1), "uCode", "Uname", new GarmentComodityId(1), "cCode", "cName", false);

            _mockFinishingOutRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishingOutReadModel>()
            {
                garmentFinishingOut.GetReadModel()
            }.AsQueryable());
            _mockFinishingOutItemRepository
            .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentFinishingOutItemReadModel, bool> > >()))
            .Returns(new List <GarmentFinishingOutItem>()
            {
                new GarmentFinishingOutItem(finishingOutItemGuid, finishingOutGuid, Guid.Empty, finishingInItemGuid, new ProductId(1), null, null, null, new SizeId(1), null, 1, new UomId(1), null, null, 1, 1, 1)
            });
            //_mockFinishingOutDetailRepository
            //    .Setup(s => s.Find(It.IsAny<Expression<Func<GarmentFinishingOutDetailReadModel, bool>>>()))
            //    .Returns(new List<GarmentFinishingOutDetail>()
            //    {
            //        new GarmentFinishingOutDetail(Guid.Empty, Guid.Empty,new SizeId(1), null, 1, new UomId(1),null )
            //    });

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

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

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

            GarmentFinishedGoodStockHistory garmentFinishedGoodStockHistory = new GarmentFinishedGoodStockHistory(Guid.NewGuid(), garmentFinishedGoodStock.Identity,
                                                                                                                  finishingOutItemGuid, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, null, "ro", "article", garmentFinishingOut.UnitId, garmentFinishingOut.UnitCode, garmentFinishingOut.UnitName,
                                                                                                                  garmentFinishingOut.ComodityId, garmentFinishingOut.ComodityCode, garmentFinishingOut.ComodityName,
                                                                                                                  new SizeId(1), null, new UomId(1), null, 1, 1, 1);

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

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

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