public void TestRemoveVideoCallConnection_ShouldReturnEmptyReader() { // Insert mock tables mockDataGenerator.InsertTable1(); mockDataGenerator.InsertTable2(); // Insert databaseManager.SetVideoCallConnection(mockDataGenerator.table1["TABLE_NUMBER"], mockDataGenerator.table2["TABLE_NUMBER"]); // Remove databaseManager.RemoveVideoCallConnection(mockDataGenerator.table1["TABLE_NUMBER"], mockDataGenerator.table2["TABLE_NUMBER"]); // Get the inserted call connection var testDbHelper = new TestDatabaseHelper(); var reader = testDbHelper.GetCallConnection(mockDataGenerator.table1["TABLE_NUMBER"], mockDataGenerator.table2["TABLE_NUMBER"]); // Try to read the reader, since the reader.HasRows does not work. try { reader.Read(); Assert.Fail(); }catch { //Ignore the catch, this is expected. } // Close the connection created by GetCallConnection(). testDbHelper.CloseConnection(); // Delete mock rows. mockDataGenerator.DeleteTable1(); mockDataGenerator.DeleteTable2(); }
public void TestConnectGuestToTable_And_DisconnectGuestFromTable() { var databaseHelper = new TestDatabaseHelper(); //Insert the mock data. mockDataGenerator.InsertTable1(); mockDataGenerator.InsertUser1(); // Insert the record. databaseManager.ConnectGuestToTable(mockDataGenerator.user1["ID"], mockDataGenerator.table1["TABLE_NUMBER"]); // Load the record var reader = databaseHelper.GetGuestToTableConnection(mockDataGenerator.user1["ID"], mockDataGenerator.table1["TABLE_NUMBER"]); reader.Read(); // Loop through records. for (int i = 0; i < reader.FieldCount; i++) { var name = reader.GetName(i); // Assert that the name of the column is either "TABLE_ID" or "GUEST_ID". Assert.IsTrue(name.Equals("TABLE_ID") || name.Equals("GUEST_ID")); var value = reader.GetValue(i); // Assert that the value of the column is the same as the inserted values. Assert.IsTrue(value.Equals(int.Parse(mockDataGenerator.user1["ID"])) || value.Equals(int.Parse(mockDataGenerator.table1["TABLE_NUMBER"]))); } // Close connection for GetGuestToTableConnection. databaseHelper.CloseConnection(); // Remove the record using DatabaseManager. databaseManager.DisconnectGuestFromTable(mockDataGenerator.user1["ID"], mockDataGenerator.table1["TABLE_NUMBER"]); // Load the record (should be empty). reader = databaseHelper.GetGuestToTableConnection(mockDataGenerator.user1["ID"], mockDataGenerator.table1["TABLE_NUMBER"]); // Try to read the reader. This should throw an exception since the reader is empty. try { reader.Read(); Assert.Fail(); } catch { //Ignore the catch, this is expected. } // Close connection for GetGuestToTableConnection databaseHelper.CloseConnection(); // Remove mock data mockDataGenerator.RemoveUser1(); mockDataGenerator.DeleteTable1(); }
public void TestSetVideoCallConnection_NonExitingCallConnection_ShouldPass() { // Insert mock tables mockDataGenerator.InsertTable1(); mockDataGenerator.InsertTable2(); // Insert databaseManager.SetVideoCallConnection(mockDataGenerator.table1["TABLE_NUMBER"], mockDataGenerator.table2["TABLE_NUMBER"]); var testDbHelper = new TestDatabaseHelper(); var reader = testDbHelper.GetCallConnection(mockDataGenerator.table1["TABLE_NUMBER"], mockDataGenerator.table2["TABLE_NUMBER"]); // Assert that the reader is returned. Assert.IsNotNull(reader); // Assert that there is data in the reader. Assert.IsTrue(reader.HasRows); // Read the first row. reader.Read(); for (int i = 0; i < reader.FieldCount; i++) { // Get the column name. var name = reader.GetName(i); // Assert that the name is either "TABLE_NUMBER" or "HOTEL_ID". Assert.IsTrue(name.Equals("TABLE_NUMBER_1") || name.Equals("TABLE_NUMBER_2")); // Get the value of the column. var value = reader.GetValue(i); // Assert that the values are those of the inserted table. Assert.IsTrue(value.Equals(int.Parse(mockDataGenerator.table1["TABLE_NUMBER"])) || value.Equals(int.Parse(mockDataGenerator.table2["TABLE_NUMBER"]))); } //Close the connection created by the user. testDbHelper.CloseConnection(); //Remove the mock data. testDbHelper.RemoveCallConnection(mockDataGenerator.table1["TABLE_NUMBER"], mockDataGenerator.table2["TABLE_NUMBER"]); mockDataGenerator.DeleteTable1(); mockDataGenerator.DeleteTable2(); }
public void DeleteTable2() { var dbHelper = new TestDatabaseHelper(); dbHelper.DeleteTable(table2["TABLE_NUMBER"], table2["HOTEL_ID"]); }
public void InsertTable1() { var dbHelper = new TestDatabaseHelper(); dbHelper.InsertTable(table1["TABLE_NUMBER"], table1["HOTEL_ID"]); }
public FbDataReader SelectUser1() { var dbHelper = new TestDatabaseHelper(); return(dbHelper.GetReaderForUser(user1["ID"])); }
public void RemoveUser2() { var dbHelper = new TestDatabaseHelper(); dbHelper.RemoveUser(user2["ID"]); }
public void InsertUser2() { var dbHelper = new TestDatabaseHelper(); dbHelper.InsertUser(user2["ID"], user2["FIRST_NAME"], user2["LAST_NAME"], user2["USER_NAME"], user2["PASSWORD"]); }