예제 #1
0
        public void GetAllTeachersClassTest()
        {
            QuizardDatabase db = null;

            Assert.DoesNotThrow(delegate
            {
                db = new QuizardDatabase();
                db.Open();
                if (!File.Exists("quizard.db"))
                {
                    int x = db.buildDB();
                    Assert.AreEqual(x, 0);
                }
            });
            Console.WriteLine("Database created");

            List <User> teachers = db.GetAllUsers(UserTypes.Teacher);

            Console.WriteLine("retrieved all students");
            Console.WriteLine("total users Count: " + teachers.Count);
            foreach (User teacher in teachers)
            {
                Console.WriteLine("teacher name: " + teacher.Name);
                List <Class> classes = db.GetTeachersClasses(teacher);
                Console.WriteLine("Retrieved all classes for teacher");
                Console.WriteLine("Total class count: " + classes.Count);
                foreach (Class iClass in classes)
                {
                    Assert.IsTrue(iClass.Teacher.rowId == teacher.rowId);
                    Console.WriteLine("Class does not contain the teacher");
                }
            }
        }