コード例 #1
0
        //[TestMethod]
        public void test_03_create_and_delete_project()
        {
            var controller = new AdminController();

            HttpContextFactory.SetCurrentContext(GetMockedHttpContext());
            controller.ControllerContext = new ControllerContext(HttpContextFactory.Current,
                                              new RouteData(), controller);

            CurrentUser currentUser = CurrentUser.getInstance();
            currentUser.Studentnummer = 3000000;

            FormCollection n = new FormCollection();
            string exception = "";
            n.Add("FormProject.name", "TestProject");
            n.Add("FormProject.description", "TestDescription");
            n.Add("FormProject.start_date", "01/01/2001");
            n.Add("FormProject.end_date", "12/12/2012");
            try
            {
                var result = (RedirectToRouteResult) controller.Create(n);
                Assert.AreEqual("List", result.RouteValues["action"]);
            }
            catch (Exception e)
            {
                exception = e.ToString();
            }
            Assert.AreEqual(exception, "");

            exception = "";

            try{
                a.DeleteProject(8);
            }
            catch (Exception e)
            {
                exception = e.ToString();
            }

            Assert.AreEqual(exception, "");
        }
コード例 #2
-1
 public void test_02_studentForm()
 {
     var controller = new AdminController();
     FormCollection a = new FormCollection();
     a.Add("student", "3000000");
     var result = (RedirectToRouteResult) controller.StudentForm(a);
     Assert.AreEqual("Student", result.RouteValues["action"]);
 }