public void GetAllAssignmentsTest() { 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 <Class> classes = db.GetAllClasses(); Console.WriteLine("Retrieved All Classes"); Console.WriteLine("Total Class count: " + classes.Count); foreach (Class iClass in classes) { Console.WriteLine("CLass Name: " + iClass.Name); List <string> names = db.getAssignments(iClass.rowId); Console.WriteLine("Total Names count for " + iClass.Name + ": " + names.Count); using (SQLiteConnection database = new SQLiteConnection("Data Source = quizard.db")) { database.Open(); using (SQLiteCommand command = database.CreateCommand()) { command.CommandText = "SELECT COUNT(*) FROM quizzes WHERE class_ID = " + iClass.rowId + ";"; Console.WriteLine("SELECT COUNT(*) FROM quizzes WHERE class_ID = " + iClass.rowId + ";"); long allUassignmentsCount = (long)command.ExecuteScalar(); Console.WriteLine("current user count: " + allUassignmentsCount); Assert.AreEqual(names.Count, allUassignmentsCount); Console.WriteLine("Counts match with " + allUassignmentsCount); } } } }
public void GetAllClassesTest() { 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 <Class> allClasses = db.GetAllClasses(); Console.WriteLine("Query successful"); Console.WriteLine("Class count = " + allClasses.Count); Assert.DoesNotThrow(delegate { using (SQLiteConnection database = new System.Data.SQLite.SQLiteConnection("Data Source = quizard.db")) { database.Open(); using (SQLiteCommand command = database.CreateCommand()) { Console.WriteLine("SELECT COUNT(*) FROM classes;"); command.CommandText = "SELECT COUNT(*) FROM classes;"; Assert.AreEqual(command.ExecuteScalar(), allClasses.Count); Console.WriteLine("Count was equal"); } } }); }