Exemplo n.º 1
0
        public void NegativeStudentsClassTest()
        {
            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> students = db.GetAllUsers();

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