public void Create_ShouldThrowException_GivenInvalidSessionID()
        {
            // Insert the master data rows in the database.
            int sessionID = SessionTestTable.InsertPlaceholder();

            // Build the CourseSchedule data row.
            CourseScheduleDataRow courseScheduleDataRow = new CourseScheduleDataRow();

            courseScheduleDataRow.CourseScheduleCode = "zzcj32kpd6huzp1n";
            courseScheduleDataRow.SessionID          = -1;
            courseScheduleDataRow.DayOfWeek          = 1;
            courseScheduleDataRow.Time = new TimeSpan(9, 15, 0);

            // Build the database connection.
            using (DatabaseConnection databaseConnection = new DatabaseConnection(TestDatabase.ConnectionString))
            {
                // Open the database connection.
                databaseConnection.Open().Wait();

                try
                {
                    // Create the CourseSchedule data row.
                    CourseScheduleDataAccessComponent courseScheduleDataAccessComponent = new CourseScheduleDataAccessComponent();
                    courseScheduleDataAccessComponent.Create(databaseConnection, courseScheduleDataRow).Wait();

                    // Validate an exception was thrown.
                    Assert.Fail();
                }
                catch (AggregateException ex)
                {
                    // Validate an SQL exception was thrown.
                    Assert.IsInstanceOfType(ex.InnerExceptions[0], typeof(SqlException));
                }
            }
        }
        public void Create_ShouldSucceed()
        {
            // Insert the master data rows in the database.
            int sessionID = SessionTestTable.InsertPlaceholder();

            // Build the CourseSchedule data row.
            CourseScheduleDataRow courseScheduleDataRow = new CourseScheduleDataRow();

            courseScheduleDataRow.CourseScheduleCode = "zzcj32kpd6huzp1n";
            courseScheduleDataRow.SessionID          = sessionID;
            courseScheduleDataRow.DayOfWeek          = 1;
            courseScheduleDataRow.Time = new TimeSpan(9, 15, 0);

            // Build the database connection.
            using (DatabaseConnection databaseConnection = new DatabaseConnection(TestDatabase.ConnectionString))
            {
                // Open the database connection.
                databaseConnection.Open().Wait();

                // Create the CourseSchedule data row.
                CourseScheduleDataAccessComponent courseScheduleDataAccessComponent = new CourseScheduleDataAccessComponent();
                courseScheduleDataAccessComponent.Create(databaseConnection, courseScheduleDataRow).Wait();
            }

            // Validate the CourseScheduleID was generated.
            Assert.AreNotEqual(0, courseScheduleDataRow.CourseScheduleID);

            // Validate the CourseSchedule data row was inserted in the database.
            CourseScheduleTestTable.AssertPresence(
                courseScheduleDataRow.CourseScheduleID,
                "zzcj32kpd6huzp1n",
                sessionID,
                1,
                new TimeSpan(9, 15, 0));
        }