public async Task GivenAnyInvocation_WhenGettingCurrentVersion_ThenReturnCurrentVersion()
        {
            var resolver = new PassthroughSchemaVersionResolver(new SchemaInformation(1, 3)
            {
                Current = 2
            });

            Assert.Equal(SchemaVersion.V2, await resolver.GetCurrentVersionAsync(default));
        internal SqlDataStoreTestsFixture(string databaseName, SchemaInformation schemaInformation)
        {
            DatabaseName      = EnsureArg.IsNotNullOrEmpty(databaseName, nameof(databaseName));
            SchemaInformation = EnsureArg.IsNotNull(schemaInformation, nameof(schemaInformation));

            IConfiguration environment = new ConfigurationBuilder()
                                         .AddEnvironmentVariables()
                                         .Build();

            string initialConnectionString = environment["SqlServer:ConnectionString"] ?? LocalConnectionString;

            _masterConnectionString = new SqlConnectionStringBuilder(initialConnectionString)
            {
                InitialCatalog = "master"
            }.ToString();
            TestConnectionString = new SqlConnectionStringBuilder(initialConnectionString)
            {
                InitialCatalog = DatabaseName
            }.ToString();

            var config = new SqlServerDataStoreConfiguration
            {
                ConnectionString = TestConnectionString,
                Initialize       = true,
                SchemaOptions    = new SqlServerSchemaOptions
                {
                    AutomaticUpdatesEnabled = true,
                },
            };

            IOptions <SqlServerDataStoreConfiguration> configOptions = Options.Create(config);

            var scriptProvider = new ScriptProvider <SchemaVersion>();

            var baseScriptProvider = new BaseScriptProvider();

            var mediator = Substitute.For <IMediator>();

            var sqlConnectionStringProvider = new DefaultSqlConnectionStringProvider(configOptions);

            var sqlConnectionFactory = new DefaultSqlConnectionFactory(sqlConnectionStringProvider);

            var schemaManagerDataStore = new SchemaManagerDataStore(sqlConnectionFactory, configOptions, NullLogger <SchemaManagerDataStore> .Instance);

            SchemaUpgradeRunner = new SchemaUpgradeRunner(scriptProvider, baseScriptProvider, NullLogger <SchemaUpgradeRunner> .Instance, sqlConnectionFactory, schemaManagerDataStore);

            _schemaInitializer = new SchemaInitializer(configOptions, schemaManagerDataStore, SchemaUpgradeRunner, SchemaInformation, sqlConnectionFactory, sqlConnectionStringProvider, mediator, NullLogger <SchemaInitializer> .Instance);

            SqlTransactionHandler = new SqlTransactionHandler();

            SqlConnectionWrapperFactory = new SqlConnectionWrapperFactory(SqlTransactionHandler, new SqlCommandWrapperFactory(), sqlConnectionFactory);

            var schemaResolver = new PassthroughSchemaVersionResolver(SchemaInformation);

            IndexDataStore = new SqlIndexDataStore(new VersionedCache <ISqlIndexDataStore>(
                                                       schemaResolver,
                                                       new[]
            {
                new SqlIndexDataStoreV1(SqlConnectionWrapperFactory),
                new SqlIndexDataStoreV2(SqlConnectionWrapperFactory),
                new SqlIndexDataStoreV3(SqlConnectionWrapperFactory),
                new SqlIndexDataStoreV4(SqlConnectionWrapperFactory),
                new SqlIndexDataStoreV5(SqlConnectionWrapperFactory),
                new SqlIndexDataStoreV6(SqlConnectionWrapperFactory),
            }));

            InstanceStore = new SqlInstanceStore(new VersionedCache <ISqlInstanceStore>(
                                                     schemaResolver,
                                                     new[]
            {
                new SqlInstanceStoreV1(SqlConnectionWrapperFactory),
                new SqlInstanceStoreV4(SqlConnectionWrapperFactory),
                new SqlInstanceStoreV6(SqlConnectionWrapperFactory),
            }));

            PartitionStore = new SqlPartitionStore(new VersionedCache <ISqlPartitionStore>(
                                                       schemaResolver,
                                                       new[]
            {
                new SqlPartitionStoreV6(SqlConnectionWrapperFactory),
            }));

            ExtendedQueryTagStore = new SqlExtendedQueryTagStore(new VersionedCache <ISqlExtendedQueryTagStore>(
                                                                     schemaResolver,
                                                                     new[]
            {
                new SqlExtendedQueryTagStoreV1(),
                new SqlExtendedQueryTagStoreV2(SqlConnectionWrapperFactory, NullLogger <SqlExtendedQueryTagStoreV2> .Instance),
                new SqlExtendedQueryTagStoreV4(SqlConnectionWrapperFactory, NullLogger <SqlExtendedQueryTagStoreV4> .Instance),
                new SqlExtendedQueryTagStoreV8(SqlConnectionWrapperFactory, NullLogger <SqlExtendedQueryTagStoreV8> .Instance),
            }));

            ExtendedQueryTagErrorStore = new SqlExtendedQueryTagErrorStore(new VersionedCache <ISqlExtendedQueryTagErrorStore>(
                                                                               schemaResolver,
                                                                               new[]
            {
                new SqlExtendedQueryTagErrorStoreV1(),
                new SqlExtendedQueryTagErrorStoreV4(SqlConnectionWrapperFactory, NullLogger <SqlExtendedQueryTagErrorStoreV4> .Instance),
                new SqlExtendedQueryTagErrorStoreV6(SqlConnectionWrapperFactory, NullLogger <SqlExtendedQueryTagErrorStoreV6> .Instance),
            }));
            IndexDataStoreTestHelper             = new SqlIndexDataStoreTestHelper(TestConnectionString);
            ExtendedQueryTagStoreTestHelper      = new ExtendedQueryTagStoreTestHelper(TestConnectionString);
            ExtendedQueryTagErrorStoreTestHelper = new ExtendedQueryTagErrorStoreTestHelper(TestConnectionString);
        }