public void IndexShoudlUseRepositoryTest()
        {
            // Arrange
            Mock<IWebNoteService> service = new Mock<IWebNoteService>();
            HomeController controller = new HomeController { WebNoteService = service.Object };

            // Act
            controller.Index();

            // Assert - method called at least once
            service.Verify(r => r.ReadAll(), Times.AtLeastOnce());
        }
        public void IndexTest()
        {
            // Arrange
            var expectedList = this.CreateNotesList();

            // Arrange Repository
            Mock<IWebNoteService> service = new Mock<IWebNoteService>();
            service.Setup(r => r.ReadAll()).Returns(expectedList);

            // Arrange Controller
            HomeController controller = new HomeController { WebNoteService = service.Object };

            // Act
            ViewResult result = controller.Index() as ViewResult;
            ViewDataDictionary viewData = result.ViewData;
            var returnedList = viewData.Model as List<NoteWithCategories>;

            // Assert
            Assert.That(returnedList, Is.EquivalentTo(expectedList));
        }
        public void IndexWasChangedTest()
        {
            // Arrange Repository
            Mock<IWebNoteService> service = new Mock<IWebNoteService>();
            service.SetupAllProperties();

            // Arrange Controller
            HomeController controller = new HomeController { WebNoteService = service.Object };

            // Act
            ViewResult result = controller.Index() as ViewResult;
            string message = result.ViewData["Message"] as string;

            // Assert
            Assert.AreNotEqual("Welcome to ASP.NET MVC!", message);
        }