示例#1
0
        public void RemoveTest()
        {
            using (var monumentsController = new MonumentsController(new MonumentsAgent()))
            {
                monumentsController.Add(new Monument()
                {
                    Id       = 1,
                    Name     = "Monument",
                    Location = "Irak"
                });
                monumentsController.Add(new Monument()
                {
                    Id       = 2,
                    Name     = "Dom",
                    Location = "Frankrijk"
                });

                var redirectResult = monumentsController.Remove("Monument");
                var result         = ((monumentsController.Index() as ViewResult).Model) as IEnumerable <Monument>;
                Assert.IsInstanceOfType(redirectResult, typeof(RedirectToActionResult));
                Assert.AreEqual(1, result.Count());
                Assert.AreEqual("Dom", result.FirstOrDefault().Name);
                Assert.AreEqual("Frankrijk", result.FirstOrDefault().Location);
            }
        }
示例#2
0
        public void IndexTest()
        {
            using (var monumentsController = new MonumentsController(new MonumentsAgent()))
            {
                var result = monumentsController.Index();

                Assert.IsInstanceOfType(result, typeof(ViewResult));
            }
        }
        public void MonumentGetTest()
        {
            using (var repo = new RepositoryMock())
            {
                var target = new MonumentsController(repo);

                IEnumerable <Monument> result = target.Get();

                Assert.AreEqual("Dom", result.First().Name);
                Assert.AreEqual(2, result.Count());
            }
        }
        public void MonumentDeletTest()
        {
            using (var repo = new RepositoryMock())
            {
                Assert.AreEqual(0, repo.TimesCalled);

                var target = new MonumentsController(repo);

                target.Delete(2);

                Assert.AreEqual(1, repo.TimesCalled);
            }
        }
        public void MonumentGetWithIdTest()
        {
            using (var repo = new RepositoryMock())
            {
                var target = new MonumentsController(repo);

                Monument result = target.Get(2);

                Assert.AreEqual("Eifeltoren", result.Name);
                Assert.AreEqual("Frankfurt", result.Location);
                Assert.AreEqual(2, result.Id);
            }
        }
示例#6
0
 public void ToevoegenMonumentTest()
 {
     using (var monumentsController = new MonumentsController(new MonumentsAgent()))
     {
         var redirectResult = monumentsController.Add(new Monument()
         {
             Name = "Monument"
         });
         var result = ((monumentsController.Index() as ViewResult).Model) as IEnumerable <Monument>;
         Assert.IsInstanceOfType(redirectResult, typeof(RedirectToActionResult));
         Assert.AreEqual(result.FirstOrDefault().Name, "Monument");
     }
 }