public async Task BlogController_Index_Model_Is_For_Latest_Post_If_There_Are_Posts_In_The_Database()
        {
            // Arrange
            // Use a new database so that our results are not interfered with by other tests.
            // If this is the first test to run, the shared SQL LocalDB instance will be created now.
            string connectionString = TestSetup.GetConnectionStringForNewDatabase();

            using (BlogContext context = new BlogContext(connectionString))
            {
                context.Posts.Add(new BlogPost()
                {
                    Title = "Title 1", Body = "Post 1", Preview = "Preview 1", PublishedAt = new DateTime(2015, 6, 10, 12, 00, 00, DateTimeKind.Utc)
                });
                context.Posts.Add(new BlogPost()
                {
                    Title = "Title 2", Body = "Post 2", Preview = "Preview 2", PublishedAt = new DateTime(2015, 6, 11, 12, 00, 00, DateTimeKind.Utc)
                });
                context.Posts.Add(new BlogPost()
                {
                    Title = "Title 3", Body = "Post 3", Preview = "Preview 3", PublishedAt = new DateTime(2015, 6, 11, 13, 00, 00, DateTimeKind.Utc)
                });

                await context.SaveChangesAsync();
            }

            using (BlogController target = CreateTarget(connectionString))
            {
                // Act
                ActionResult result = await target.Index();

                // Assert
                Assert.IsNotNull(result);
                Assert.IsInstanceOfType(result, typeof(ViewResult));

                ViewResult view = result as ViewResult;

                Assert.IsNotNull(view.Model);
                Assert.IsInstanceOfType(view.Model, typeof(HomePageViewModel));
                Assert.AreEqual(string.Empty, view.ViewName);

                HomePageViewModel model = view.Model as HomePageViewModel;

                Assert.AreEqual("Preview 3", model.LatestPostPreview);
                Assert.AreEqual("Title 3", model.LatestPostTitle);
            }
        }
        public async Task BlogController_Index_Returns_Null_Model_If_There_Are_No_Posts_In_The_Database()
        {
            // Arrange
            // Use the database we know is empty and has no data in it.
            // If this is the first test to run, the shared SQL LocalDB instance will be created now.
            string connectionString = TestSetup.GetConnectionStringForDatabase(EmptyDatabaseName);

            using (BlogController target = CreateTarget(connectionString))
            {
                // Act
                ActionResult result = await target.Index();

                // Assert
                Assert.IsNotNull(result);
                Assert.IsInstanceOfType(result, typeof(ViewResult));

                ViewResult view = result as ViewResult;

                Assert.IsNull(view.Model);
                Assert.AreEqual(string.Empty, view.ViewName);
            }
        }