Beispiel #1
0
        public void Can_export_database_creation_script()
        {
            const string schema = "custom_schema";
            var          store  = new MsSqlStreamStoreV3(new MsSqlStreamStoreV3Settings("server=.;database=sss")
            {
                Schema = schema,
            });

            var sqlScript = store.GetSchemaCreationScript();

            sqlScript.ShouldBe(new ScriptsV3.Scripts("custom_schema").CreateSchema);
        }
Beispiel #2
0
        public async Task <IStreamStore> GetStreamStore(string schema)
        {
            var settings = new MsSqlStreamStoreV3Settings(ConnectionString)
            {
                Schema    = schema,
                GetUtcNow = () => GetUtcNow(),
                DisableDeletionTracking = _disableDeletionTracking
            };
            var store = new MsSqlStreamStoreV3(settings);
            await store.CreateSchema();

            return(store);
        }
Beispiel #3
0
        public async Task <MsSqlStreamStoreV3> GetMsSqlStreamStore()
        {
            await CreateDatabase();

            var settings = new MsSqlStreamStoreV3Settings(ConnectionString)
            {
                Schema    = _schema,
                GetUtcNow = () => GetUtcNow()
            };

            var store = new MsSqlStreamStoreV3(settings);
            await store.CreateSchema();

            return(store);
        }
Beispiel #4
0
 private async Task Init()
 {
     await _databaseInstance.CreateDatabase();
     var settings = new MsSqlStreamStoreV3Settings(ConnectionString)
     {
         Schema = _schema,
         GetUtcNow = () => GetUtcNow(),
         DisableDeletionTracking = _disableDeletionTracking
     };
     Store = new MsSqlStreamStoreV3(settings);
     if (_createSchema)
     {
         await Store.CreateSchemaIfNotExists();
     }
 }
        public async Task Can_migrate()
        {
            // Set up an old schema + data.
            var schema    = "baz";
            var v2Fixture = new MsSqlStreamStoreFixture(schema, deleteDatabaseOnDispose: false);
            var v2Store   = await v2Fixture.GetMsSqlStreamStore();

            await v2Store.AppendToStream("stream-1",
                                         ExpectedVersion.NoStream,
                                         StreamStoreAcceptanceTests.CreateNewStreamMessages(1, 2, 3));

            await v2Store.AppendToStream("stream-2",
                                         ExpectedVersion.NoStream,
                                         StreamStoreAcceptanceTests.CreateNewStreamMessages(1, 2, 3));

            await v2Store.SetStreamMetadata("stream-1", ExpectedVersion.Any, maxAge : 10, maxCount : 20);

            v2Store.Dispose();
            v2Fixture.Dispose();

            var settings = new MsSqlStreamStoreV3Settings(v2Fixture.ConnectionString)
            {
                Schema = schema,
            };

            var v3Store = new MsSqlStreamStoreV3(settings);

            var checkSchemaResult = await v3Store.CheckSchema();

            checkSchemaResult.IsMatch().ShouldBeFalse();

            var progress = new Progress <MigrateProgress>();

            progress.ProgressChanged += (_, migrateProgress) =>
                                        _testOutputHelper.WriteLine($"Migration stage complete: {migrateProgress.Stage}");

            await v3Store.Migrate(progress, CancellationToken.None);

            checkSchemaResult = await v3Store.CheckSchema();

            checkSchemaResult.IsMatch().ShouldBeTrue();

            var listStreamsResult = await v3Store.ListStreams(Pattern.EndsWith("1"));

            listStreamsResult.StreamIds.Length.ShouldBe(2);

            v3Store.Dispose();
        }
Beispiel #6
0
        public async Task Can_migrate()
        {
            // Set up an old schema + data.
            var schema    = "baz";
            var v2Fixture = new MsSqlStreamStoreFixture(schema, deleteDatabaseOnDispose: false);
            var v2Store   = await v2Fixture.GetMsSqlStreamStore();

            await v2Store.AppendToStream("stream-1",
                                         ExpectedVersion.NoStream,
                                         StreamStoreAcceptanceTests.CreateNewStreamMessages(1, 2, 3));

            await v2Store.AppendToStream("stream-2",
                                         ExpectedVersion.NoStream,
                                         StreamStoreAcceptanceTests.CreateNewStreamMessages(1, 2, 3));

            await v2Store.SetStreamMetadata("stream-1", ExpectedVersion.Any, maxAge : 10, maxCount : 20);

            v2Store.Dispose();
            v2Fixture.Dispose();

            var settings = new MsSqlStreamStoreV3Settings(v2Fixture.ConnectionString)
            {
                Schema = schema,
            };

            var v3Store = new MsSqlStreamStoreV3(settings);

            var checkSchemaResult = await v3Store.CheckSchema();

            checkSchemaResult.IsMatch().ShouldBeFalse();

            await v3Store.Migrate(CancellationToken.None);

            checkSchemaResult = await v3Store.CheckSchema();

            checkSchemaResult.IsMatch().ShouldBeTrue();

            v3Store.Dispose();
        }