public HttpResponseMessage Put(int id, BlogEntry newValue)
        {
            var blogEntry = Get(id);
            blogEntry.Title = newValue.Title;

            return Request.CreateResponse(HttpStatusCode.Accepted);
        }
 public void Insert(BlogEntry blogEntry)
 {
     _blogEntries.Add(blogEntry);
 }
 public HttpResponseMessage Post(BlogEntry blogEntry)
 {
     _repository.Insert(blogEntry);
     return Request.CreateResponse(HttpStatusCode.Created, blogEntry);
 }
        public void Post_NewBlogEntry_BlogEntryAddedToRepository()
        {
            var mockedRepository = new FakeReposiory();

            var blogEntryController = CreateController(mockedRepository);
            var blogEntry = new BlogEntry { Title = "My new blogEntry" };

            blogEntryController.Post(blogEntry);

            Assert.AreEqual(1, mockedRepository.Get().Count());
        }
        public void Put_BlogEntryFound_TitleUpdated()
        {
            var blogEntry = new BlogEntry { Id = 1, Title = "MyTitle" };
            var stubbedRepository = MockRepository.GenerateStub<IBlogEntryRepository>();
            stubbedRepository.Stub(repository => repository.Get()).Return(new List<BlogEntry> { blogEntry });

            var controller = CreateController(stubbedRepository);

            var entryWithNewTitle = new BlogEntry { Title = "The new title" };

            controller.Put(1, entryWithNewTitle);

            Assert.AreEqual("The new title", blogEntry.Title);
        }
        public void Put_BlogEntryFound_StatusCodeIsAccepted()
        {
            var blogEntry = new BlogEntry { Id = 1, Title = "MyTitle" };
            var stubbedRepository = MockRepository.GenerateStub<IBlogEntryRepository>();
            stubbedRepository.Stub(repository => repository.Get()).Return(new List<BlogEntry> { blogEntry });

            var controller = CreateController(stubbedRepository);

            var entryWithNewTitle = new BlogEntry { Title = "The new title" };

            var response = controller.Put(1, entryWithNewTitle);

            Assert.AreEqual(HttpStatusCode.Accepted, response.StatusCode);
        }
        public void Post_NewBlogEntry_StatusCodeIsCreated()
        {
            var mockedRepository = new FakeReposiory();

            var blogEntryController = CreateController(mockedRepository);

            var blogEntry = new BlogEntry { Title = "My new blogEntry" };

            var response = blogEntryController.Post(blogEntry);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
        }