예제 #1
0
        public void CanReturnView()
        {
            //Arrange
            var controller = new GreetingController(mock.Object);
            //Act
            var result = controller.Index("BDMView");

            //Assert
            Assert.IsInstanceOf(typeof(ViewResult), result);
        }
예제 #2
0
        public void ShowRightView()
        {
            //Arrange
            GreetingController target = new GreetingController(mock.Object);
            //Act
            ViewResult result = (ViewResult)target.Index("BDMView");

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(result.ViewName, "");
        }
예제 #3
0
        public void IndexView_True()
        {
            // Arrange - create the controller
            GreetingController target = new GreetingController(mock.Object);

            // Act - call the action method
            ViewResult result = target.Index("BDMView");

            // Assert - check the result
            Assert.AreEqual("", result.ViewName);
        }
        public void Index()
        {
            // Arrange
            GreetingController controller = new GreetingController();

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

            // Assert
            Assert.IsNotNull(result);
        }
예제 #5
0
        public void Index_Sets_Name_On_Model()
        {
            var expectedName = "ExampleString";
            var controller   = new GreetingController();

            var result = controller.Index(expectedName);

            var model = (GreetingModel)result.Model;

            Assert.Equal(expectedName, model.Name);
        }
예제 #6
0
        public void Index_Default_AllGreetings()
        {
            // Arrange - create the controller
            GreetingController target = new GreetingController(mock.Object);

            // Act - call the action method
            IEnumerable <Greeting> result       = (IEnumerable <Greeting>)target.Index("BDMView").Model;
            List <Greeting>        GreetingView = result.ToList <Greeting>();

            // Assert - check the result
            CollectionAssert.AreEqual(mock.Object.Greetings, GreetingView);
        }
예제 #7
0
        public void ViewGreetingList()
        {
            //Arrange
            GreetingController target = new GreetingController(mock.Object);
            //Act
            IEnumerable <Greeting> result = (IEnumerable <Greeting>)target.Index("BDMView").Model;

            Greeting[] cArray = result.ToArray();
            //Assert
            CollectionAssert.AllItemsAreInstancesOfType(result, typeof(Greeting));
            Assert.AreEqual(5, cArray.Length);
            Assert.IsTrue(cArray[0].GreetingHeader == "Greeting 1");
            Assert.IsTrue(cArray[1].GreetingHeader == "Greeting 2");
            Assert.IsTrue(cArray[2].GreetingHeader == "Greeting 3");
        }