public void Create_ShouldSucceed() { // Build the Session data row. SessionDataRow sessionDataRow = new SessionDataRow(); sessionDataRow.SessionCode = "6dk61ufcuzp3f7vs"; sessionDataRow.Name = "Session Alpha"; sessionDataRow.StartDate = new DateTime(2001, 1, 1); // Build the database connection. using (DatabaseConnection databaseConnection = new DatabaseConnection(TestDatabase.ConnectionString)) { // Open the database connection. databaseConnection.Open().Wait(); // Create the Session data row. SessionDataAccessComponent sessionDataAccessComponent = new SessionDataAccessComponent(); sessionDataAccessComponent.Create(databaseConnection, sessionDataRow).Wait(); } // Validate the SessionID was generated. Assert.AreNotEqual(0, sessionDataRow.SessionID); // Validate the Session data row was inserted in the database. SessionTestTable.AssertPresence( sessionDataRow.SessionID, "6dk61ufcuzp3f7vs", "Session Alpha", new DateTime(2001, 1, 1)); }
public void Update_ShouldSucceed() { // Insert the Session data row in the database. int sessionID = SessionTestTable.InsertWithValues( "6dk61ufcuzp3f7vs", "Session Alpha", new DateTime(2001, 1, 1)); // Build the Session data row. SessionDataRow sessionDataRow = new SessionDataRow(); sessionDataRow.SessionID = sessionID; sessionDataRow.SessionCode = "n3p4y556gt9f17hw"; sessionDataRow.Name = "Session Bravo"; sessionDataRow.StartDate = new DateTime(2002, 2, 2); // Build the database connection. using (DatabaseConnection databaseConnection = new DatabaseConnection(TestDatabase.ConnectionString)) { // Open the database connection. databaseConnection.Open().Wait(); // Update the Session data row. SessionDataAccessComponent sessionDataAccessComponent = new SessionDataAccessComponent(); sessionDataAccessComponent.Update(databaseConnection, sessionDataRow).Wait(); } // Validate the Session data row was updated in the database. SessionTestTable.AssertPresence( sessionID, "n3p4y556gt9f17hw", "Session Bravo", new DateTime(2002, 2, 2)); }