Пример #1
0
        public async void Flow_tests()
        {
            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 forTheCreatingPut = await requester.PutEntityAsJsonAsync(person);

                forTheCreatingPut.TheResponse(should => should
                                              .BeSuccessful()
                                              .HaveStatus(HttpStatusCode.Created));

                var forTheGet = await requester.GetAsync(person.Id.ToString());

                forTheGet.TheResponse(should => should
                                      .BeSuccessful()
                                      .BeJsonResponse()
                                      .HaveSpecificValueFor("firstName", "Daniel"));

                person.Age = 42;
                var forTheUpdatingPut = await requester.PutEntityAsJsonAsync(person);

                forTheUpdatingPut.TheResponse(should => should
                                              .BeSuccessful()
                                              .HaveStatus(HttpStatusCode.OK));

                var forTheDelete = await requester.DeleteAsync(person.Id.ToString());

                forTheDelete.TheResponse(should => should
                                         .BeSuccessful()
                                         .HaveStatus(HttpStatusCode.OK));

                var forTheCreatingPost = await requester.PostEntityAsJsonAsync(person);

                forTheCreatingPost.TheResponse(should => should
                                               .BeSuccessful()
                                               .HaveStatus(HttpStatusCode.Created)
                                               .BeJsonResponse()
                                               .NotHavingSpecificValueFor("id", person.Id));
            }
        }