public async Task <IActionResult> Delete(string id) { Guid guid = Guid.Parse(id); VerifyUser(); RemoveGarmentAvalComponentCommand command = new RemoveGarmentAvalComponentCommand(guid); var data = await Mediator.Send(command); return(Ok(data.Identity)); }
public async Task Handle_Cutting_ShouldSuccess() { // Arrange RemoveGarmentAvalComponentCommandHandler unitUnderTest = CreateRemoveGarmentAvalComponentCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; Guid avalComponentGuid = Guid.NewGuid(); RemoveGarmentAvalComponentCommand removeGarmentAvalComponentCommand = new RemoveGarmentAvalComponentCommand(avalComponentGuid); _mockGarmentAvalComponentRepository .Setup(s => s.Query) .Returns(new List <GarmentAvalComponentReadModel>() { new GarmentAvalComponent(avalComponentGuid, "AvalComponentNo", new UnitDepartmentId(1), "UnitCode", "UnitName", "CUTTING", "RONo", "Article", new GarmentComodityId(1), "ComodityCode", "ComodityName", DateTimeOffset.Now).GetReadModel() }.AsQueryable()); _mockGarmentAvalComponentItemRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentAvalComponentItemReadModel, bool> > >())) .Returns(new List <GarmentAvalComponentItem>() { new GarmentAvalComponentItem(Guid.Empty, avalComponentGuid, Guid.Empty, Guid.Empty, Guid.Empty, new ProductId(1), null, null, null, null, 0, 0, new SizeId(1), null, 0, 1) }); _mockGarmentAvalComponentRepository .Setup(s => s.Update(It.IsAny <GarmentAvalComponent>())) .Returns(Task.FromResult(It.IsAny <GarmentAvalComponent>())); _mockGarmentAvalComponentItemRepository .Setup(s => s.Update(It.IsAny <GarmentAvalComponentItem>())) .Returns(Task.FromResult(It.IsAny <GarmentAvalComponentItem>())); _mockGarmentCuttingInDetailRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentCuttingInDetailReadModel, bool> > >())) .Returns(new List <GarmentCuttingInDetail>() { new GarmentCuttingInDetail(Guid.Empty, Guid.Empty, Guid.Empty, 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) }); _mockGarmentCuttingInDetailRepository .Setup(s => s.Update(It.IsAny <GarmentCuttingInDetail>())) .Returns(Task.FromResult(It.IsAny <GarmentCuttingInDetail>())); _MockStorage .Setup(x => x.Save()) .Verifiable(); // Act var result = await unitUnderTest.Handle(removeGarmentAvalComponentCommand, cancellationToken); // Assert result.Should().NotBeNull(); }