public async Task <IActionResult> Put(string id, [FromBody] UpdateGarmentFinishingOutCommand 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 UpdateGarmentFinishingOutCommand(); // Action var validator = GetValidationRules(); var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldHaveError(); }
public void Place_HaveError_Date() { // Arrange var validator = GetValidationRules(); var unitUnderTest = new UpdateGarmentFinishingOutCommand(); unitUnderTest.FinishingOutDate = DateTimeOffset.Now.AddDays(-7); unitUnderTest.FinishingInDate = DateTimeOffset.Now; // Action var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldHaveError(); }
public async Task Handle_StateUnderTest_ExpectedBehavior() { // Arrange Guid finishingInItemGuid = Guid.NewGuid(); Guid finishingOutGuid = Guid.NewGuid(); Guid finishingInId = Guid.NewGuid(); UpdateGarmentFinishingOutCommandHandler unitUnderTest = CreateUpdateGarmentFinishingOutCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; UpdateGarmentFinishingOutCommand UpdateGarmentFinishingOutCommand = new UpdateGarmentFinishingOutCommand() { RONo = "RONo", Unit = new UnitDepartment(1, "UnitCode", "UnitName"), UnitTo = new UnitDepartment(2, "UnitCode2", "UnitName2"), Article = "Article", IsDifferentSize = true, FinishingTo = "FINISHING", 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 = finishingInId, 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 } } } }, }; UpdateGarmentFinishingOutCommand.SetIdentity(finishingOutGuid); _mockFinishingOutRepository .Setup(s => s.Query) .Returns(new List <GarmentFinishingOutReadModel>() { new GarmentFinishingOutReadModel(finishingOutGuid) }.AsQueryable()); _mockFinishingOutItemRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentFinishingOutItemReadModel, bool> > >())) .Returns(new List <GarmentFinishingOutItem>() { new GarmentFinishingOutItem(Guid.Empty, 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()); _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>())); _MockStorage .Setup(x => x.Save()) .Verifiable(); // Act var result = await unitUnderTest.Handle(UpdateGarmentFinishingOutCommand, cancellationToken); // Assert result.Should().NotBeNull(); }
public void Place_NotHaveError() { // Arrange Guid id = Guid.NewGuid(); var unitUnderTest = new UpdateGarmentFinishingOutCommand() { Article = "Article", Comodity = new GarmentComodity() { Id = 1, Code = "Code", Name = "Name" }, FinishingOutDate = DateTimeOffset.Now, FinishingInDate = DateTimeOffset.Now, FinishingOutNo = "FinishingOutNo", FinishingTo = "FinishingTo", IsDifferentSize = true, RONo = "RONo", Unit = new UnitDepartment() { Id = 1, Code = "Code", Name = "Name" }, UnitTo = new UnitDepartment() { Id = 1, Code = "Code", Name = "Name" }, Items = new List <GarmentFinishingOutItemValueObject>() { new GarmentFinishingOutItemValueObject() { BasicPrice = 1, Color = "Color", DesignColor = "DesignColor", FinishingInId = id, FinishingInItemId = id, FinishingInQuantity = 2, FinishingOutId = id, Id = id, IsDifferentSize = true, IsSave = true, Price = 1, Product = new Product() { Id = 1, Code = "Code", Name = "Name" }, Quantity = 1, RemainingQuantity = 2, Size = new SizeValueObject() { Id = 1, Size = "Size" }, TotalQuantity = 1, Uom = new Uom() { Id = 1, Unit = "Unit" }, Details = new List <GarmentFinishingOutDetailValueObject>() { new GarmentFinishingOutDetailValueObject() { Id = id, FinishingOutItemId = id, Quantity = 1, Size = new SizeValueObject() { Id = 1, Size = "Size" }, Uom = new Uom() { Id = 1, Unit = "Unit" } } } } }, }; // Action var validator = GetValidationRules(); var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldNotHaveError(); }