public async Task <IActionResult> Put(string id, [FromBody] UpdateGarmentCuttingInCommand command) { Guid guid = Guid.Parse(id); command.SetIdentity(guid); VerifyUser(); var order = await Mediator.Send(command); return(Ok(order.Identity)); }
public async Task Handle_StateUnderTest_ExpectedBehavior() { // Arrange Guid cuttingInGuid = Guid.NewGuid(); Guid preparingItemGuid = Guid.NewGuid(); UpdateGarmentCuttingInCommandHandler unitUnderTest = CreateUpdateGarmentCuttingInCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; UpdateGarmentCuttingInCommand UpdateGarmentCuttingInCommand = new UpdateGarmentCuttingInCommand() { RONo = "RONo", Unit = new UnitDepartment(1, "UnitCode", "UnitName"), CuttingInDate = DateTimeOffset.Now, Items = new List <GarmentCuttingInItemValueObject> { new GarmentCuttingInItemValueObject { Details = new List <GarmentCuttingInDetailValueObject> { new GarmentCuttingInDetailValueObject { PreparingItemId = preparingItemGuid, Product = new Product(1, "ProductCode", "ProductName"), PreparingUom = new Uom(1, "UomUnit"), CuttingInUom = new Uom(2, "PCS"), IsSave = true, } } } }, }; UpdateGarmentCuttingInCommand.SetIdentity(cuttingInGuid); _mockCuttingInRepository .Setup(s => s.Query) .Returns(new List <GarmentCuttingInReadModel>() { new GarmentCuttingInReadModel(cuttingInGuid) }.AsQueryable()); _mockCuttingInItemRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentCuttingInItemReadModel, bool> > >())) .Returns(new List <GarmentCuttingInItem>() { new GarmentCuttingInItem(Guid.Empty, Guid.Empty, Guid.Empty, 0, null, Guid.Empty, null) }); _mockCuttingInDetailRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentCuttingInDetailReadModel, bool> > >())) .Returns(new List <GarmentCuttingInDetail>() { new GarmentCuttingInDetail(Guid.Empty, Guid.Empty, preparingItemGuid, Guid.Empty, Guid.Empty, new ProductId(1), null, null, null, null, 0, new UomId(1), null, 0, new UomId(1), null, 0, 0, 1, 1, null) }); _mockPreparingItemRepository .Setup(s => s.Query) .Returns(new List <GarmentPreparingItemReadModel> { new GarmentPreparingItemReadModel(preparingItemGuid) }.AsQueryable()); _mockCuttingInRepository .Setup(s => s.Update(It.IsAny <GarmentCuttingIn>())) .Returns(Task.FromResult(It.IsAny <GarmentCuttingIn>())); _mockCuttingInItemRepository .Setup(s => s.Update(It.IsAny <GarmentCuttingInItem>())) .Returns(Task.FromResult(It.IsAny <GarmentCuttingInItem>())); _mockCuttingInDetailRepository .Setup(s => s.Update(It.IsAny <GarmentCuttingInDetail>())) .Returns(Task.FromResult(It.IsAny <GarmentCuttingInDetail>())); _mockPreparingItemRepository .Setup(s => s.Update(It.IsAny <GarmentPreparingItem>())) .Returns(Task.FromResult(It.IsAny <GarmentPreparingItem>())); _MockStorage .Setup(x => x.Save()) .Verifiable(); // Act var result = await unitUnderTest.Handle(UpdateGarmentCuttingInCommand, cancellationToken); // Assert result.Should().NotBeNull(); }