예제 #1
0
        public void Should_Be_Able_To_Get_Typed_Object()
        {
            /* Setup */
            var expected = _repo.Get(1);

            /* Test */
            var result = _client.Get <Todo>("api/todos/1");

            /* Assert */
            Assert.That(result.Body.Id, Is.EqualTo(expected.Id));
            Assert.That(result.Body.Description, Is.EqualTo(expected.Description));
            Assert.That(result.Body.IsCompleted, Is.EqualTo(expected.IsCompleted));
        }
예제 #2
0
        public void Should_Be_Able_To_Put_Object()
        {
            /* Setup */
            const string newDescription = "This is the new description";
            var          existingTodo   = _repo.Get(2);

            existingTodo.Description = newDescription;

            /* Test */
            var result = _client.Put <string>("api/todos", existingTodo);

            /* Assert */
            Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));
            Assert.That(_repo.Get(2).Description, Is.EqualTo(newDescription));
        }
예제 #3
0
        public void Should_Be_Able_To_Perform_Delete()
        {
            /* Setup */
            var todo = new Todo {
                Description = "Do the dishes"
            };
            var saved = _repo.Add(todo);

            /* Test */
            var response = _client.Delete <string>(string.Format("api/todos/{0}", saved.Id));

            /* Assert */
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            Assert.That(_repo.Get(saved.Id), Is.Null, "Todo should have been removed");
        }