public async Task <IActionResult> GetBaskets(string basketId) { var result = await this.getBasketsById .Execute(GetBasketsByIdRequest.Create(basketId)); if (null == result) { return(NotFound()); } return(Ok(result)); }
public async Task GetBasketsById_NullBasketId_ThrowsException() { //Arrange string basketId = null; var mock = GetBasketsByIdMock.Create(); var target = mock.Target; var request = GetBasketsByIdRequest.Create(basketId); //Act async Task execute() => await target.Execute(request); //Assert await Assert.ThrowsAsync <ArgumentException>(execute); }
public async Task GetBasketsById_WithId_ReturnsBasket() { //Arrange var basketId = Guid.NewGuid().ToString(); var mock = GetBasketsByIdMock.Create(); var target = mock.Target; var request = GetBasketsByIdRequest.Create(basketId); //Act var actual = await target.Execute(request); //Assert mock.BasketsRepositoryMock.Verify(rep => rep.Get(basketId), Times.Once()); }