Esempio n. 1
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();
        }
Esempio n. 2
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);
        }