public void CreateGetView_True()
        {
            // Arrange - create the controller
            GreetingController target = new GreetingController(mock.Object);

            // Act - call the action method
            var result = target.Create() as ViewResult;

            // Assert - check the result
            Assert.AreEqual("", result.ViewName);
        }
        public void CreatePost_CannotCreate_InvalidGreeting()
        {
            // Arrange - create the controller
            Greeting           Greeting = new Greeting();
            GreetingController target   = new GreetingController(mock.Object);

            // Act - call the action method
            target.ModelState.AddModelError("error", "error");
            ViewResult result = target.Create(Greeting) as ViewResult;

            // Assert - check the result
            mock.Verify(m => m.SaveGreeting(It.IsAny <Greeting>()), Times.Never);
            Assert.IsInstanceOf(typeof(Greeting), result.ViewData.Model);
            Assert.IsInstanceOf(typeof(ViewResult), result);
        }
        public void CreatePost_CanCreate_ValidGreeting()
        {
            // Arrange - create the controller
            GreetingController target   = new GreetingController(mock.Object);
            Greeting           Greeting = new Greeting {
                GreetingId = 6, GreetingHeader = "Greeting 1", GreetingBody = "Test Greeting"
            };

            // Act - call the action method
            RedirectToRouteResult result = (RedirectToRouteResult)target.Create(Greeting);

            // Assert - check the result
            mock.Verify(m => m.SaveGreeting(Greeting), Times.Once);
            Assert.IsFalse(result.Permanent);
            Assert.AreEqual("Home", result.RouteValues["controller"]);
            Assert.AreEqual("BDMView", result.RouteValues["action"]);
        }