public async Task <IActionResult> DeleteBasket(string basketId) { if (string.IsNullOrEmpty(basketId)) { return(this.BadRequest()); } await this.deleteBasket .Execute(DeleteBasketRequest.Create(basketId)); return(Ok()); }
public async Task DeleteBasket_NullBasketId_ThrowsException() { //Arrange string basketId = null; var mock = DeleteBasketMock.Create(); var target = mock.Target; var request = DeleteBasketRequest.Create(basketId); //Act async Task execute() => await target.Execute(request); //Assert await Assert.ThrowsAsync <ArgumentException>(execute); }
public async Task GetAllBasketsTests_ValidRequest_RepositoryCalledOnce() { //Arrange var basketId = Guid.NewGuid().ToString(); var mock = DeleteBasketMock.Create(); var target = mock.Target; var request = DeleteBasketRequest.Create(basketId); //Act await target.Execute(request); //Assert mock.BasketsRepositoryMock.Verify(rep => rep.Delete(basketId), Times.Once()); }