示例#1
0
        public void GetAllDepartmentHeadsClassTest()
        {
            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> dps = db.GetAllUsers(UserTypes.DepartmentHead);

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