public void GetBlogEntries(int page, int pageSize)
        {
            // Act
            var controller = new BlogEntriesController(_logger, _entityBL, _blogEntryTagBL, _blogEntryCommentBL);
            var result     = controller.GetBlogEntries(string.Empty, string.Empty, string.Empty, page, pageSize) as OkNegotiatedContentResult <PagedList>;

            // Assert

            Assert.AreEqual(result.Content.Content.Count, pageSize);
        }
        public void GetBlogEntriesByHeaderUrl(int id, string headerUrl)
        {
            // Act
            var controller = new BlogEntriesController(_logger, _entityBL, _blogEntryTagBL, _blogEntryCommentBL);
            var result     = controller.GetBlogEntriesByHeaderUrl(headerUrl) as OkNegotiatedContentResult <BlogEntry>;

            // Assert
            Assert.NotNull(result);
            Assert.NotNull(result.Content);
            Assert.AreEqual(id, result.Content.Id);
        }
        public void PostBlogEntries()
        {
            var newEntity             = _fixture.Build <BlogEntryModel>().Without(x => x.Id).Create();
            int _maxEntityIdBeforeAdd = _entities.Max(a => a.Id);

            // Act
            var controller = new BlogEntriesController(_logger, _entityBL, _blogEntryTagBL, _blogEntryCommentBL);
            var result     = controller.PostBlogEntries(newEntity) as OkNegotiatedContentResult <JsonResponse>;

            // Assert

            Assert.That(result.Content.Data, Is.EqualTo(_entities.Last()));
            Assert.That(_maxEntityIdBeforeAdd + 1, Is.EqualTo(_entities.Last().Id));
        }
        public void PutBlogEntries(int id)
        {
            var updateEntity = _fixture.Build <BlogEntryModel>().With(x => x.Id, id).Create();

            // Act
            var controller = new BlogEntriesController(_logger, _entityBL, _blogEntryTagBL, _blogEntryCommentBL);
            var result     = controller.PutBlogEntries(id, updateEntity) as OkNegotiatedContentResult <JsonResponse>;

            // Assert

            var resultEntity = result.Content.Data as BlogEntry;

            Assert.That(resultEntity.LastActivityDate, Is.Not.EqualTo(DateTime.MinValue));
            Assert.That(resultEntity.Id, Is.EqualTo(1)); // hasn't changed
        }
 public BlogEntriesUnitTests()
 {
     testController = new BlogEntriesController(fakeBlogService);
     listBlogs      = new List <BlogEntry>()
     {
         new BlogEntry {
             Id = 1, UserName = "******", Entry = "Entry1", Title = "Title1", EntryDate = DateTime.Parse("2015-01-01")
         },
         new BlogEntry {
             Id = 2, UserName = "******", Entry = "Entry2", Title = "Title2", EntryDate = DateTime.Parse("2015-01-01")
         },
         new BlogEntry {
             Id = 3, UserName = "******", Entry = "Entry3", Title = "Title3", EntryDate = DateTime.Parse("2015-01-01")
         },
         new BlogEntry {
             Id = 4, UserName = "******", Entry = "Entry4", Title = "Title4", EntryDate = DateTime.Parse("2015-01-01")
         }
     };
 }