public void Mock_GetViewResultIndex_Test()
        {
            //Arrange
            DbSetup();
            SuggestionsController controller = new SuggestionsController(mock.Object);
            //Act
            var result = controller.Index();

            //Assert
            Assert.IsType <ViewResult>(result);
        }
Exemplo n.º 2
0
        public void Get_ViewIndex_Test()
        {
            //Arrange
            SuggestionsController controller = new SuggestionsController(db);

            //Act
            IActionResult result = controller.Index();

            //Assert
            Assert.IsType <ViewResult>(result);
        }
        public void Mock_ConfirmEntry_Test()
        {
            //Arrange
            DbSetup();
            SuggestionsController controller = new SuggestionsController(mock.Object);
            var testItem = new Suggestion {
                Id = 1, City = "Portland", Country = "United States", Description = "The City of Roses"
            };
            //Act
            ViewResult indexView  = controller.Index() as ViewResult;
            var        collection = indexView.ViewData.Model as IEnumerable <Suggestion>;

            // Assert
            Assert.Contains <Suggestion>(testItem, collection);
        }
        public void DB_CreateNewEntry_Test()
        {
            // Arrange
            SuggestionsController controller     = new SuggestionsController(db);
            Suggestion            testSuggestion = new Suggestion();

            testSuggestion.Description = "TestDb Suggestion";

            // Act
            controller.Create(testSuggestion);
            var collection = (controller.Index() as ViewResult).ViewData.Model as IEnumerable <Suggestion>;

            // Assert
            Assert.Contains <Suggestion>(testSuggestion, collection);
        }
        public void Mock_ConfirmEntry_Test() //Confirms presence of known entry
        {
            // Arrange
            DbSetup();
            SuggestionsController controller     = new SuggestionsController(mock.Object);
            Suggestion            testSuggestion = new Suggestion();

            testSuggestion.Description  = "Its.. France";
            testSuggestion.SuggestionId = 1;

            // Act
            ViewResult indexView  = controller.Index() as ViewResult;
            var        collection = indexView.ViewData.Model as IEnumerable <Suggestion>;

            // Assert
            Assert.Contains <Suggestion>(testSuggestion, collection);
        }
Exemplo n.º 6
0
        public void DB_ViewIndex_Test()
        {
            // Arrange
            SuggestionsController controller     = new SuggestionsController(db);
            Suggestion            testSuggestion = new Suggestion();

            testSuggestion.Description = "So quiet.";

            Location testLocation = new Location();

            testLocation.LocationName = "New Mexico";
            db.Save(testLocation);

            // Act
            controller.Create(testSuggestion, testLocation.LocationId);
            ViewResult indexView = new SuggestionsController().Index() as ViewResult;
            IEnumerable <Suggestion> collection = (controller.Index() as ViewResult).ViewData.Model as IEnumerable <Suggestion>;

            // Assert
            Assert.Contains(testSuggestion, collection);
        }