public async Task Request_GET_returnsNotFound() { //Arrange var mockHttpMessageHandler = sut(HttpStatusCode.NotFound, "Not Found"); var request = new JsonRequest(mockHttpClientFactory.Object); //Act var ex = await Assert.ThrowsAsync <ApiException>(() => request.Get <Person>("http://webAddress", It.IsAny <CancellationToken>())); //Assert Assert.True(ex.StatusCode == 404); }
public async Task Request_GET_returnsModel200() { //Arrange var mockHttpMessageHandler = sut(HttpStatusCode.OK, "{'id':1,'fullName':'John Smith','age':21}"); var request = new JsonRequest(mockHttpClientFactory.Object); //Act var result = await request.Get <Person>("http://webAddress", It.IsAny <CancellationToken>()); //Assert Assert.Equal(result, new Person { Id = 1, FullName = "John Smith", Age = 21 }); }
private IEnumerator Start() { var getRequest = JsonRequest.Get($"{Host}/todos/1"); yield return(SendWithLog(getRequest)); var postRequest = JsonRequest.Post($"{Host}/todos", Vector2.zero); yield return(SendWithLog(postRequest)); var putRequest = JsonRequest.Put($"{Host}/todos/1", Vector2.zero); yield return(SendWithLog(putRequest)); var deleteRequest = JsonRequest.Delete($"{Host}/todos/1"); yield return(SendWithLog(deleteRequest)); }