Exemplo n.º 1
0
        public async void Can_use_the_HttpRequester()
        {
            var person = new Person
            {
                Id = Guid.NewGuid(),
                FirstName = "Daniel",
                LastName = "Wertheim",
                Age = 35
            };

            using (var requester = new HttpRequester($"{_server.BaseAddress}/api/persons/", _server.Handler))
            {
                var forThePut = await requester.PutEntityAsync(person);
                forThePut.TheResponse(should => should
                    .BeSuccessful()
                    .HaveStatus(HttpStatusCode.Created));

                var forTheGet = await requester.GetAsync(person.Id.ToString());
                forTheGet.TheResponse(should => should
                    .BeSuccessful()
                    .BeJsonResponse()
                    .HaveSpecificValue("FirstName", "Daniel"));

                var getResponse = await requester.GetAsync<Person>(person.Id.ToString());
                var retrieved = getResponse.Content;
                retrieved.Should().NotBeNull();
                retrieved.FirstName.Should().Be("Daniel");
            }
        }