public async Task ClearAsyncIgnoresMissingItem()
        {
            // arrange
            using (new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                // arrange
                var item       = new CoursePath(Guid.NewGuid(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid());
                var repository = new CoursePathRepository(_database.SqlServerRepositoryOptions);

                // act
                await repository.ClearAsync(item.Key, item.Version).ConfigureAwait(false);

                // assert
                Assert.True(true);
            }
        }
        public async Task ClearAsyncRemovesExistingItem()
        {
            // arrange
            using (new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var item = new CoursePath(Guid.NewGuid(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid());
                using (var connection = new SqlConnection(_database.ConnectionString))
                {
                    await connection.ExecuteAsync("INSERT INTO [dbo].[CoursePath] ([Key], [Name], [Slug], [Version]) VALUES (@Key, @Name, @Slug, @Version)", item).ConfigureAwait(false);
                }

                // act
                var repository = new CoursePathRepository(_database.SqlServerRepositoryOptions);
                await repository.ClearAsync(item.Key, item.Version).ConfigureAwait(false);

                // assert
                using (var connection = new SqlConnection(_database.ConnectionString))
                {
                    var saved = await connection.QuerySingleOrDefaultAsync <CoursePath>("SELECT [Key], [Name], [Slug], [Version] FROM [dbo].[CoursePath] WHERE [Key] = @Key", new { item.Key }).ConfigureAwait(false);

                    Assert.Null(saved);
                }
            }
        }
        public async Task ClearAsyncThrowsOnVersionMismatch()
        {
            // arrange
            using (new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var existing = new CoursePath(Guid.NewGuid(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid());
                using (var connection = new SqlConnection(_database.ConnectionString))
                {
                    await connection.ExecuteAsync("INSERT INTO [dbo].[CoursePath] ([Key], [Name], [Slug], [Version]) VALUES (@Key, @Name, @Slug, @Version)", existing).ConfigureAwait(false);
                }

                // act
                var repository = new CoursePathRepository(_database.SqlServerRepositoryOptions);
                var item       = existing.WithVersion(Guid.NewGuid());
                var ex         = await Assert.ThrowsAsync <ConcurrencyException>(() => repository.ClearAsync(item.Key, item.Version)).ConfigureAwait(false);

                // assert
                Assert.Equal(existing.Version, ex.StoredVersion);
                Assert.Equal(item.Version, ex.CurrentVersion);
            }
        }