Example #1
0
        public void TestMethod1()
        {
            //Make the virtual context that has User database set and Course database set
            var context = new TestNLDS_V_Context();

            //make test user with empry courses list
            ICollection<Course> course_collection = new Collection<Course>();
            User test = new User { ID = 1, username = "******", password = "******", email = "*****@*****.**", phone = 1231231234, selfDescription = "why", courses = course_collection };

            //add user and course to virtual database set
            context.Users.Add(test);

            context.Courses.Add(new Course { ID = 2, name = "test101", school = "uiuc", classInfo = "info", year = 2016, season = Season.Fall });

            //Gain the controller
            var controller = new UsersController(context, test);
            controller.set_currentUser(test); //current user = test

            string[] test_array = { "2" };

            //add course to the user
            var result = controller.AddCourses(test_array);

            Assert.IsNotNull(result);

            //check it is not null
            Assert.IsNotNull(test.courses);
        }
Example #2
0
 public void TestCreateUser()
 {
     var testdb = new TestNLDS_V_Context();
     User testuser = new User { ID = 3, username = "******", password = "******", books = new List<Book>(), courses = new List<Course>() };
     var controller = new UsersController(testdb, testuser);
     ActionResult result = controller.Create(testuser);
     // System.Diagnostics.Debug.WriteLine(testdb.Users.Find(3).username);
     Assert.AreEqual(testdb.Users.Find(3).username, "kevinly");
 }