Exemplo n.º 1
0
        public void CourseController_should_Edit_And_Save()
        {
            CourseController controller = new CourseController();

            //FormCollection form = new FormCollection();

            //form["CourseName"] = "CSTesting";
            //form["Monday"] = "True";
            //form["StartHour"] = "14";

            var course = new Course
                             {
                                 CourseName = "CSTesting",
                                 Monday = true,
                                 StartHour = 14,
                                 EndHour = 17,
                                 AssignedProfessor = null
                             };
            var result = controller.Edit(course, "139", "3");

            Assert.IsNotNull(result, "Expected client side redirect");
            Assert.AreEqual("Course Updated",controller.ViewData["Message"], "Expected another message!!");
            //Assert.AreEqual(controller.);
        }
Exemplo n.º 2
0
 public void CourseController_should_return_all_Prof_and_selected_index()
 {
     CourseController c = new CourseController();
     var result = c.Edit("3") as ViewResult;
     Assert.IsNotNull(result);
     var viewData = result.ViewData;
     var course = result.ViewData.Model as Course;
     Assert.AreEqual("Course Edit", viewData["Title"], "Expected different title");
     Assert.AreEqual("Edit Course Details!", viewData["Message"], "Expected different message");
     Assert.AreEqual(0, viewData["SelectedIndex"], "Expected different selected index");
     Assert.AreEqual(20, (viewData["AllProfsView"] as IEnumerable<Professor>).Count(), "Expected different count");
     Assert.IsNotNull(course, "Expected a course");
 }
Exemplo n.º 3
0
 public void CourseController_Should_not_Edit_Unknown_Courses()
 {
     CourseController c = new CourseController();
     var result = c.Edit("245345") as ViewResult;
     Assert.IsNull(result.ViewData.Model, "Expected null");
 }
Exemplo n.º 4
0
 public void CourseController_Should_Edit_Known_Courses()
 {
     CourseController c = new CourseController();
     var result = c.Edit("2") as ViewResult;
     Assert.IsNotNull(result.ViewData.Model, "Expected a course");
 }
Exemplo n.º 5
0
 public void CourseController_Should_Contain_Index_Method_Which_Takes_No_Argument()
 {
     CourseController c = new CourseController();
     ActionResult result = c.Index();
     Assert.IsNotNull(result, "Expected courses");
 }
Exemplo n.º 6
0
        public void CourseController_Should_return_Courses()
        {
            var c = new CourseController();
            var result = c.Index() as ViewResult;
            Assert.IsNotNull(result);

            var viewData = result.ViewData;
            var courses = result.ViewData.Model as IEnumerable<Course>;
            Assert.AreEqual("Course management", viewData["Title"], "Expected different title");
            Assert.AreEqual("Create - Edit - Delete Courses", viewData["Message"], "Expected different message");
            Assert.IsNotNull(courses, "Expected sequence of courses");
            Assert.AreEqual(40, courses.Count(), "Expected 26 courses");
        }