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 Create_ShouldThrowException_GivenDuplicateSessionCode()
        {
            // Insert the duplicate Session data row in the database.
            int sessionID = SessionTestTable.InsertPlaceholder(sessionCode: "6dk61ufcuzp3f7vs");

            // 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();

                try
                {
                    // Create the Session data row.
                    SessionDataAccessComponent sessionDataAccessComponent = new SessionDataAccessComponent();
                    sessionDataAccessComponent.Create(databaseConnection, sessionDataRow).Wait();

                    // Validate an exception was thrown.
                    Assert.Fail();
                }
                catch (AggregateException ex)
                {
                    // Validate an SQL exception was thrown.
                    Assert.IsInstanceOfType(ex.InnerExceptions[0], typeof(SqlException));
                }
            }
        }