Example #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");
            }
        }
Example #2
0
        public void Can_use_the_When_construct()
        {
            var person = new Person
            {
                Id = Guid.NewGuid(),
                FirstName = "Daniel",
                LastName = "Wertheim",
                Age = 35
            };

            When.PutAsJson($"{_server.BaseAddress}/api/persons/", person)
                .TheResponse(should => should
                    .BeSuccessful()
                    .HaveStatus(HttpStatusCode.Created));

            When.GetOfJson(_server.BaseAddress + "api/persons/" + person.Id)
                .TheResponse(should => should
                    .BeSuccessful()
                    .BeJsonResponse()
                    .HaveSpecificValue("FirstName", "Daniel"));
        }
Example #3
0
        public HttpResponseMessage Put(Person person)
        {
            _personsStore.Store(person);

            return Request.CreateResponse(HttpStatusCode.Created);
        }
Example #4
0
 public void Store(Person person)
 {
     _personState.AddOrUpdate(person.Id, person, (eid, ep) => person);
 }