public async Task Handle_StateUnderTest_ExpectedBehavior() { // Arrange Guid id = Guid.NewGuid(); UpdateIsReceivedGarmentAvalProductCommandHandler unitUnderTest = CreateUpdateIsReceivedGarmentAvalProductCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; UpdateIsReceivedGarmentAvalProductCommand request = new UpdateIsReceivedGarmentAvalProductCommand(new List <string>() { id.ToString() }, true) { }; _mockGarmentAvalProductItemRepository .Setup(s => s.Query) .Returns(new List <GarmentAvalProductItemReadModel>() { new GarmentAvalProductItemReadModel(id) }.AsQueryable()); _mockGarmentAvalProductItemRepository .Setup(s => s.Update(It.IsAny <GarmentAvalProductItem>())) .Returns(Task.FromResult(It.IsAny <GarmentAvalProductItem>())); _MockStorage .Setup(x => x.Save()) .Verifiable(); var result = await unitUnderTest.Handle(request, cancellationToken); // Assert result.Should().BeTrue(); }
public async Task <IActionResult> UpdateIsReceived([FromBody] UpdateIsReceivedGarmentAvalProductCommand command) { VerifyUser(); var order = await Mediator.Send(command); return(Ok()); }
public async Task UpdateIsReceived_Return_OK() { // Arrange var unitUnderTest = CreateGarmentAvalProductController(); _MockMediator .Setup(s => s.Send(It.IsAny <UpdateIsReceivedGarmentAvalProductCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true); // Act var command = new UpdateIsReceivedGarmentAvalProductCommand(new List <string>() { "ids" }, true); var result = await unitUnderTest.UpdateIsReceived(command); // Assert Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(result)); }