/// <summary>
 /// Enables you to create a large set of blog entries for
 /// testing purposes.
 /// </summary>
 public static void CreateBlogEntries(BlogController controller, int count)
 {
     for (int i = 0; i < count; i++)
     {
         var name = "Blog Entry " + i.ToString();
         var blogEntryToCreate = BlogEntryFactory.GetWithName(name);
         controller.Create(blogEntryToCreate);
     }
 }
        public void ShowNewBlogEntries()
        {
            // Arrange
            var repository = new FakeBlogRepository();
            var controller = new BlogController(repository);

            // Act
            var result = (ViewResult)controller.Index();

            // Assert
            CollectionAssert.AllItemsAreInstancesOfType((ICollection)result.ViewData.Model, typeof(BlogEntry));
        }
        public void CreateBlogEntry()
        {
            // Arrange
            var repository = new FakeBlogRepository();
            var controller = new BlogController(repository);
            var blogEntryToCreate = new BlogEntry();

            // Act
            controller.Create(blogEntryToCreate);
            var result = (ViewResult)controller.Index();

            // Assert
            var firstEntry = ((IList)result.ViewData.Model)[0];
            Assert.AreSame(blogEntryToCreate, firstEntry);
        }
        public void IndexReturnsBlogEntryByName()
        {
            // Arrange
            var repository = new FakeBlogRepository();
            var blogController = new BlogController(repository);
            var archiveController = new ArchiveController(repository);

            blogController.Create(new BlogEntry { Name = "Test-1", DatePublished = new DateTime(2010, 12, 25) });
            blogController.Create(new BlogEntry { Name = "Test-2", DatePublished = new DateTime(2010, 12, 25) });

            // Act
            var result = (ViewResult)archiveController.Index(null, null, null, "Test-2");

            // Assert
            var blogEntries = (IList<BlogEntry>)result.ViewData.Model;
            Assert.AreEqual(1, blogEntries.Count);
            Assert.AreEqual("Test-2", blogEntries[0].Name);
        }
 public void Initialize()
 {
     _controllerFactory = new ControllerFactory();
     _blogController = _controllerFactory.GetBlogController();
 }