public async void SendPutRequestAndReturnOkWhenUpdateTodoAsync() { // Arrange _mockHandler.Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)); var client = new HttpClient(_mockHandler.Object); client.BaseAddress = new Uri("https://localhost:44376"); _mockClientFactory.Setup(x => x.CreateClient("TodoAppClient")).Returns(client); var sut = new TodoItemService(_mockClientFactory.Object); // Act var result = await sut.UpdateTodoAsync(It.IsAny <int>(), It.IsAny <TodoItemForUpdateDto>()); // Assert _mockHandler.Protected().Verify( "SendAsync", Times.Exactly(1), ItExpr.Is <HttpRequestMessage>(req => req.Method == HttpMethod.Put), ItExpr.IsAny <CancellationToken>()); Assert.Equal(HttpStatusCode.OK, result.StatusCode); }