Exemplo n.º 1
0
        public async Task Request_POST_CreatesModel()
        {
            //Arrange
            var mockHttpMessageHandler = sut(HttpStatusCode.Created, "{'id':1,'fullName':'John Smith','age':21}");
            var request = new JsonRequest(mockHttpClientFactory.Object);
            //Act
            var result = await request.Post <Person>("http://webAddress", new Person { Id = 1, FullName = "John Smith", Age = 21 }, It.IsAny <CancellationToken>());

            //Assert
            Assert.Equal(result, new Person {
                Id = 1, FullName = "John Smith", Age = 21
            });
        }
Exemplo n.º 2
0
        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));
        }