예제 #1
0
        public void NegativetasClassTest()
        {
            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> tas = db.GetAllUsers();

            Console.WriteLine("retrieved all TeachingAssistant");
            Console.WriteLine("total users Count: " + tas.Count);
            foreach (User ta in tas)
            {
                if (ta.Role != UserTypes.TeachingAssistant)
                {
                    Console.WriteLine("TeachingAssistant name: " + ta.Name);
                    List <Class> classes = db.GetTAClasses(ta);
                    Console.WriteLine("Retrieved all classes for TeachingAssistant");
                    Console.WriteLine("Total class count: " + classes.Count);
                    foreach (Class iClass in classes)
                    {
                        Console.WriteLine("TeachingAssistant class: " + iClass.Name);
                        bool found = false;
                        foreach (User cStud in iClass.AssistantTeachers)
                        {
                            if (cStud.rowId == ta.rowId)
                            {
                                found = true;
                            }
                        }
                        Assert.IsFalse(found);
                        Console.WriteLine("Class does not contain the TeachingAssistant");
                    }
                }
            }
        }