public void Create_ShouldSucceed() { // Insert the master data rows in the database. int courseScheduleID = CourseScheduleTestTable.InsertPlaceholder(); // Build the CourseGroup data row. CourseGroupDataRow courseGroupDataRow = new CourseGroupDataRow(); courseGroupDataRow.CourseGroupCode = "5s1cgndj6e5x0uvz"; courseGroupDataRow.CourseScheduleID = courseScheduleID; courseGroupDataRow.PlacesCount = 1; // Build the database connection. using (DatabaseConnection databaseConnection = new DatabaseConnection(TestDatabase.ConnectionString)) { // Open the database connection. databaseConnection.Open().Wait(); // Create the CourseGroup data row. CourseGroupDataAccessComponent courseGroupDataAccessComponent = new CourseGroupDataAccessComponent(); courseGroupDataAccessComponent.Create(databaseConnection, courseGroupDataRow).Wait(); } // Validate the CourseGroupID was generated. Assert.AreNotEqual(0, courseGroupDataRow.CourseGroupID); // Validate the CourseGroup data row was inserted in the database. CourseGroupTestTable.AssertPresence( courseGroupDataRow.CourseGroupID, "5s1cgndj6e5x0uvz", courseScheduleID, 1); }
public void Update_ShouldSucceed() { // Insert the first master data rows in the database. int firstCourseScheduleID = CourseScheduleTestTable.InsertPlaceholder(); // Insert the second master data rows in the database. int secondCourseScheduleID = CourseScheduleTestTable.InsertPlaceholder(); // Insert the CourseGroup data row in the database. int courseGroupID = CourseGroupTestTable.InsertWithValues( "5s1cgndj6e5x0uvz", firstCourseScheduleID, 1); // Build the CourseGroup data row. CourseGroupDataRow courseGroupDataRow = new CourseGroupDataRow(); courseGroupDataRow.CourseGroupID = courseGroupID; courseGroupDataRow.CourseGroupCode = "78zcn25ynkaz50ef"; courseGroupDataRow.CourseScheduleID = secondCourseScheduleID; courseGroupDataRow.PlacesCount = 2; // Build the database connection. using (DatabaseConnection databaseConnection = new DatabaseConnection(TestDatabase.ConnectionString)) { // Open the database connection. databaseConnection.Open().Wait(); // Update the CourseGroup data row. CourseGroupDataAccessComponent courseGroupDataAccessComponent = new CourseGroupDataAccessComponent(); courseGroupDataAccessComponent.Update(databaseConnection, courseGroupDataRow).Wait(); } // Validate the CourseGroup data row was updated in the database. CourseGroupTestTable.AssertPresence( courseGroupID, "78zcn25ynkaz50ef", secondCourseScheduleID, 2); }