public async Task Handle_StateUnderTest_ExpectedBehavior() { // Arrange Guid id = Guid.NewGuid(); RemoveGarmentDeliveryReturnCommandHandler unitUnderTest = CreateRemoveGarmentDeliveryReturnCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; _mockGarmentDeliveryReturnRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentDeliveryReturnReadModel, bool> > >())) .Returns(new List <GarmentDeliveryReturn>() { new GarmentDeliveryReturn(id, "drNo", "roNo", "article", 1, "unitDONo", 1, "preparingId", DateTimeOffset.Now, "returnType", new UnitDepartmentId(1), "unitCode", "unitName", new StorageId(1), "storageName", "storageCode", true) }); _mockGarmentDeliveryReturnItemRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentDeliveryReturnItemReadModel, bool> > >())) .Returns(new List <GarmentDeliveryReturnItem>() { new GarmentDeliveryReturnItem(id, id, 1, 1, "preparingItemId", new ProductId(1), "productCode", "FABRIC", "designColor", "roNo", 1, new UomId(1), "uomUnit") }); _mockGarmentDeliveryReturnItemRepository .Setup(s => s.Update(It.IsAny <GarmentDeliveryReturnItem>())) .Returns(Task.FromResult(It.IsAny <GarmentDeliveryReturnItem>())); GarmentPreparingItem garmentPreparingItem = new GarmentPreparingItem(id, 1, new Domain.GarmentPreparings.ValueObjects.ProductId(1), "productCode", "productName", "designColor", 1, new Domain.GarmentPreparings.ValueObjects.UomId(1), "uomUnit", "FABRIC", 1, 1, id, null); _mockGarmentPreparingItemRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentPreparingItemReadModel, bool> > >())) .Returns(new List <GarmentPreparingItem>() { garmentPreparingItem }); _mockGarmentPreparingItemRepository .Setup(s => s.Update(It.IsAny <GarmentPreparingItem>())) .Returns(Task.FromResult(It.IsAny <GarmentPreparingItem>())); _mockGarmentDeliveryReturnRepository .Setup(s => s.Update(It.IsAny <GarmentDeliveryReturn>())) .Returns(Task.FromResult(It.IsAny <GarmentDeliveryReturn>())); _MockStorage .Setup(x => x.Save()) .Verifiable(); // Act RemoveGarmentDeliveryReturnCommand request = new RemoveGarmentDeliveryReturnCommand(); request.SetId(id); var result = await unitUnderTest.Handle(request, cancellationToken); // Assert result.Should().NotBeNull(); }
public GarmentPreparingItemDto(GarmentPreparingItem garmentPreparingItem) { Id = garmentPreparingItem.Identity; LastModifiedDate = garmentPreparingItem.AuditTrail.ModifiedDate ?? garmentPreparingItem.AuditTrail.CreatedDate; LastModifiedBy = garmentPreparingItem.AuditTrail.ModifiedBy ?? garmentPreparingItem.AuditTrail.CreatedBy; UENItemId = garmentPreparingItem.UENItemId; Product = new Product(garmentPreparingItem.ProductId.Value, garmentPreparingItem.ProductName, garmentPreparingItem.ProductCode); DesignColor = garmentPreparingItem.DesignColor; Quantity = (decimal)garmentPreparingItem.Quantity; Uom = new Uom(garmentPreparingItem.UomId.Value, garmentPreparingItem.UomUnit); FabricType = garmentPreparingItem.FabricType; RemainingQuantity = (decimal)garmentPreparingItem.RemainingQuantity; BasicPrice = (decimal)garmentPreparingItem.BasicPrice; GarmentPreparingId = garmentPreparingItem.GarmentPreparingId; ROSource = garmentPreparingItem.ROSource; }
public GarmentAvalProductItemDto(GarmentAvalProductItem garmentAvalProductItem) { Id = garmentAvalProductItem.Identity; LastModifiedDate = garmentAvalProductItem.AuditTrail.ModifiedDate ?? garmentAvalProductItem.AuditTrail.CreatedDate; LastModifiedBy = garmentAvalProductItem.AuditTrail.ModifiedBy ?? garmentAvalProductItem.AuditTrail.CreatedBy; APId = garmentAvalProductItem.APId; PreparingId = new GarmentPreparing(garmentAvalProductItem.PreparingId.Value, "", ""); PreparingItemId = new GarmentPreparingItem(garmentAvalProductItem.PreparingItemId.Value, null, "", 0); Product = new Product(garmentAvalProductItem.ProductId.Value, garmentAvalProductItem.ProductName, garmentAvalProductItem.ProductCode); DesignColor = garmentAvalProductItem.DesignColor; Quantity = garmentAvalProductItem.Quantity; Uom = new Uom(garmentAvalProductItem.UomId.Value, garmentAvalProductItem.UomUnit); BasicPrice = garmentAvalProductItem.BasicPrice; IsReceived = garmentAvalProductItem.IsReceived; }
public void should_success_instantiate() { Guid id = Guid.NewGuid(); GarmentPreparingItem item = new GarmentPreparingItem(new GarmentPreparingItemReadModel(id)); //item.setUenItemId(1); item.setProduct(new ProductId(1)); item.setProductCode("newProductCode"); item.setProductName("newProductName"); item.setDesignColor("newDesignColor"); //item.setQuantity(1); item.setUomId(new UomId(1)); item.setUomUnit("newUomUnit"); item.setFabricType("newFabricType"); //item.setBasicPrice(1); item.setProduct(new ProductId(1)); Assert.NotNull(item); }
public async Task Handle_when_item_save_is_true() { // Arrange Guid id = Guid.NewGuid(); UpdateGarmentDeliveryReturnCommandHandler unitUnderTest = CreateUpdateGarmentDeliveryReturnCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; var garmentDeliveryReturn = new GarmentDeliveryReturn(id, "drNo", "roNo", "article", 1, "unitDONo", 1, "preparingId", DateTimeOffset.Now, "returnType", new UnitDepartmentId(1), "unitCode", "unitName", new StorageId(1), "storageName", "storageCode", true); _mockGarmentDeliveryReturnRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentDeliveryReturnReadModel, bool> > >())) .Returns(new List <GarmentDeliveryReturn>() { garmentDeliveryReturn }); _mockGarmentDeliveryReturnItemRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentDeliveryReturnItemReadModel, bool> > >())) .Returns(new List <GarmentDeliveryReturnItem>() { new GarmentDeliveryReturnItem(id, id, 1, 1, "preparingItemId", new ProductId(1), "productCode", "FABRIC", "designColor", "roNo", 1, new UomId(1), "uomUnit") }); GarmentPreparingItem garmentDeliveryReturnItem = new GarmentPreparingItem(id, 1, new Domain.GarmentPreparings.ValueObjects.ProductId(1), "productCode", "productName", "designColor", 1, new Domain.GarmentPreparings.ValueObjects.UomId(1), "uomUnit", "fabricType", 1, 1, id, null); _mockGarmentPreparingItemRepository .Setup(s => s.Query) .Returns(new List <GarmentPreparingItemReadModel>() { garmentDeliveryReturnItem.GetReadModel() }.AsQueryable()); _mockGarmentDeliveryReturnItemRepository .Setup(s => s.Update(It.IsAny <GarmentDeliveryReturnItem>())) .Returns(Task.FromResult(It.IsAny <GarmentDeliveryReturnItem>())); _mockGarmentPreparingItemRepository .Setup(s => s.Update(It.IsAny <GarmentPreparingItem>())) .Returns(Task.FromResult(It.IsAny <GarmentPreparingItem>())); _mockGarmentDeliveryReturnRepository .Setup(s => s.Update(It.IsAny <GarmentDeliveryReturn>())) .Returns(Task.FromResult(It.IsAny <GarmentDeliveryReturn>())); _MockStorage .Setup(x => x.Save()) .Verifiable(); UpdateGarmentDeliveryReturnCommand request = new UpdateGarmentDeliveryReturnCommand() { Article = "Article", DRNo = "DRNo", IsUsed = true, PreparingId = id.ToString(), ReturnDate = DateTimeOffset.Now, ReturnType = "ReturnType", RONo = "RONo", Storage = new Storage() { Id = 1, Code = "Code", Name = "Name" }, UENId = 1, UnitDOId = 1, UnitDONo = "UnitDONo", Unit = new UnitDepartment() { Id = 1, Code = "Code", Name = "Name" }, Items = new List <GarmentDeliveryReturnItemValueObject>() { new GarmentDeliveryReturnItemValueObject() { DesignColor = "DesignColor", DRId = id, Id = id, IsSave = true, PreparingItemId = id.ToString(), Product = new Product() { Id = 1, Code = "Code", Name = "FABRIC" }, Quantity = 1, QuantityUENItem = 1, RemainingQuantityPreparingItem = 1, RONo = "RONo", UENItemId = 1, UnitDOItemId = 1, Uom = new Uom() { Id = 1, Unit = "Unit" }, } } }; // Act var result = await unitUnderTest.Handle(request, cancellationToken); // Assert result.Should().NotBeNull(); }