Exemplo n.º 1
0
        public void Contact()
        {
            // Arrange
            HomeController controller = new HomeController();

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

            // Assert
            Assert.IsNotNull(result);
        }
Exemplo n.º 2
0
        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 About()
        {
            // Arrange
            HomeController controller = new HomeController();

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

            // Assert
            Assert.AreEqual("Your application description page.", result.ViewBag.Message);
        }
Exemplo n.º 4
0
        public void AddToSubjectTableFailTest()
        {
            CreateDataFile();

            // Mock a request with missing data
            var querystring = new System.Collections.Specialized.NameValueCollection { { "Email", "12345" } };
            var mock = new Mock<ControllerContext>();
            mock.SetupGet(p => p.HttpContext.Request.QueryString).Returns(querystring);

            HomeController controller = new HomeController();
            controller.ControllerContext = mock.Object;
            controller.AddToSubjectTable();
        }
Exemplo n.º 5
0
        public void AddToSubjectTableTest()
        {
            CreateDataFile();
            NameValueCollection querystring = new NameValueCollection {
                { "Email", "*****@*****.**" },
                { "FirstName", "blake" },
                { "LastName", "b" },
                { "Password", "12345" },
                { "PageNumber", "0" },
                { "SortBy", "0" }
            };
            var mock = new Mock<ControllerContext>();
            mock.SetupGet(p => p.HttpContext.Request.QueryString).Returns(querystring);

            HomeController controller = new HomeController();
            controller.ControllerContext = mock.Object;

            ActionResult target = controller.AddToSubjectTable();

            Assert.IsNotNull(target);
            // Test that the datastore was actually updated
            Assert.IsTrue(((target as ViewResult).Model as IndexModel).Response.Total > 1);
        }
Exemplo n.º 6
0
 public void RemoveSubjectTest()
 {
     CreateDataFile();
     NameValueCollection querystring = new NameValueCollection {
         { "Email", "1@1" },
         { "PageNumber", "0" },
         { "SortBy", "0" }
     };
     var mock = new Mock<ControllerContext>();
     mock.SetupGet(p => p.HttpContext.Request.QueryString).Returns(querystring);
     HomeController controller = new HomeController();
     controller.ControllerContext = mock.Object;
     var target = controller.RemoveSubject();
     Assert.IsNotNull(target);
     QueryResponse response = ((target as ViewResult).Model as IndexModel).Response;
     Assert.IsTrue(response.Subjects.Where(sub => sub.Email == "1@1").Count() == 0);
 }
Exemplo n.º 7
0
 public void IndexTest()
 {
     CreateDataFile();
     HomeController target = new HomeController();
     Assert.IsNotNull(target);
 }
Exemplo n.º 8
0
 public void UpdateSubjectTableTest()
 {
     CreateDataFile();
     NameValueCollection querystring = new NameValueCollection {
         { "PageNumber", "14" },
         { "SortBy", "0" }
     };
     var mock = new Mock<ControllerContext>();
     mock.SetupGet(p => p.HttpContext.Request.QueryString).Returns(querystring);
     HomeController controller = new HomeController();
     controller.ControllerContext = mock.Object;
     var target = controller.UpdateSubjectTable();
     Assert.IsNotNull(target);
     Assert.IsTrue(((target as ViewResult).Model as IndexModel).PageOptions.PageNumber == 14);
 }
Exemplo n.º 9
0
 public void UniqueCheckTestTrue()
 {
     CreateDataFile();
     NameValueCollection querystring = new NameValueCollection {
         { "Email", "#&*$^#*&^$" },
     };
     var mock = new Mock<ControllerContext>();
     mock.SetupGet(p => p.HttpContext.Request.QueryString).Returns(querystring);
     HomeController controller = new HomeController();
     controller.ControllerContext = mock.Object;
     var target = controller.UniqueCheck();
     Assert.IsTrue(target);
 }