Beispiel #1
0
        public void IndexTest()
        {
            IAnimalAgent mock = new AnimalAgentMock();

            using (var target = new AnimalController(mock))
            {
                IActionResult result = target.Index().Result;

                Assert.IsInstanceOfType(result, typeof(ViewResult));
            }
        }
Beispiel #2
0
        public void ModelFromIndexTest()
        {
            IAnimalAgent mock = new AnimalAgentMock();

            using (var target = new AnimalController(mock))
            {
                IActionResult result = target.Index().Result;
                var           model  = (result as ViewResult).Model as IEnumerable <Animal>;

                Assert.AreEqual(4, model.Count());

                Assert.IsTrue(model.Any(animal => animal.Title == "Croissant" && animal.Description == "Technically not an animal"));
                Assert.IsTrue(model.Any(animal => animal.Title == "Giraffe" && animal.Description == "Long necked creature"));
                Assert.IsTrue(model.Any(animal => animal.Title == "Monkey" && animal.Description == "Likes to swing on branches"));
                Assert.IsTrue(model.Any(animal => animal.Title == "Snoop Lion" && animal.Description == "420"));
            }
        }