public void Create_WhenCalled_RequestMethodShouldBePost() { var item = new { Id = 1, Name = "a" }; _helper.Setup(hlpr => hlpr.CreateHttpContent(item, "a")) .Returns(new StringContent("a")); _api = new PersonAPIs(_helper.Object); var result = _api.Create("a", "b"); _messageHandler .Protected() .Verify( "SendAsync", Times.Exactly(TimesCalled), ItExpr.Is <HttpRequestMessage>(req => req.Method == HttpMethod.Post), ItExpr.IsAny <CancellationToken>()); }
public void Create_WhenCalled_RequestUriMustBeEqualToExpectedUri() { _uri = new Uri(APISettings.UriBase + "persongroups/a/persons"); var item = new { Id = 1, Name = "a" }; _helper.Setup(hlpr => hlpr.CreateHttpContent(item, "a")) .Returns(new StringContent("a")); _api = new PersonAPIs(_helper.Object); var result = _api.Create("a", "b"); _messageHandler .Protected() .Verify( "SendAsync", Times.Exactly(TimesCalled), ItExpr.Is <HttpRequestMessage>(req => req.RequestUri == _uri), ItExpr.IsAny <CancellationToken>()); }