Наследование: GuestBook.Controllers.BaseController
Пример #1
0
        public void IndexViewTest()
        {
            var service = new Mock<IGuestBookService>();
            const int bookId = 1;
            service.Setup(s => s.GetDefaultGuestBook(bookId)).Returns(new GuestBookModel()
            {
                GuestBookId = bookId,
                GuestBookName = "Book name"
            });
            var messageModels = new List<MessageModel>
            {
                new MessageModel() { MessageId = 1, Body = "message 1"},
                new MessageModel() { MessageId = 2, Body = "message 2"}
            };
            service.Setup(s2 => s2.LoadMessagesInBook(bookId)).Returns(messageModels);

            var home = new HomeController(service.Object);

            var result = home.Index(1) as ViewResult;
            
            Assert.IsNotNull(result);
            
            var model = result.Model as GuestBook.ModelView.MessagesInGuestBooksModelview;
            Assert.IsNotNull(model);
            Assert.AreEqual(model.Messages.Count(), messageModels.Count);
            Assert.AreEqual(result.ViewName, MVC.Home.Views.Index);



        }
        public void Index()
        {
            // Arrange
            HomeController controller = new HomeController();

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

            // Assert
            Assert.AreEqual("Modify this template to jump-start your ASP.NET MVC application.", result.ViewBag.Message);
        }
        public void Contact()
        {
            // Arrange
            HomeController controller = new HomeController();

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

            // Assert
            Assert.IsNotNull(result);
        }
Пример #4
0
        public void Index()
        {
            // 排列
            HomeController controller = new HomeController();

            // 操作
            ViewResult result = controller.Index() as ViewResult;

            // 断言
            Assert.AreEqual("修改此模板以快速启动你的 ASP.NET MVC 应用程序。", result.ViewBag.Message);
        }
Пример #5
0
        public void Contact()
        {
            // 排列
            HomeController controller = new HomeController();

            // 操作
            ViewResult result = controller.Contact() as ViewResult;

            // 断言
            Assert.IsNotNull(result);
        }