public void QueriesInSetsAndUpdatesOneByOne() { Document <Entity>().With(x => x.Number); store.Initialize(); for (int i = 0; i < 200; i++) { store.Insert(new DocumentTable("Entities"), NewId(), new { Discriminator = typeof(Entity).AssemblyQualifiedName, Version = 0, Document = configuration.Serializer.Serialize(new Entity()) }); } // bump the version of the configuration UseMigrations(new InlineMigration(1)); var counter = new TracingDocumentStoreDecorator(store); new DocumentMigrationRunner().Run(counter).Wait(); // 1+2: Entities table => 100 rows // 3: Entities table => 0 rows counter.Queries.Count(x => x.Name == "Entities").ShouldBe(3); // each document is being updated individually counter.Updates.Count.ShouldBe(200); }
public void DoesNotRetrieveDocumentIfNoReprojectionOrMigrationIsNeededButUpdatesVersion() { Document <Entity>().With(x => x.Number); Document <OtherEntity>().With(x => x.Number); // add migration for same version and one for other document UseMigrations( new InlineMigration(1, new ChangeDocument <Entity>((serializer, bytes) => bytes)), new InlineMigration(2, new ChangeDocument <OtherEntity>((serializer, bytes) => bytes))); store.Initialize(); var id = NewId(); var table = configuration.GetDesignFor <Entity>().Table; store.Insert(table, id, new { AwaitsReprojection = false, Discriminator = typeof(Entity).AssemblyQualifiedName, Version = 1, Document = configuration.Serializer.Serialize(new Entity()) }); var counter = new TracingDocumentStoreDecorator(store); new DocumentMigrationRunner().Run(counter).Wait(); var row = store.Get(table, id); counter.Gets.ShouldBeEmpty(); row[table.VersionColumn].ShouldBe(2); }
public void DoesNotRetrieveDocumentIfNoReprojectionOrMigrationIsNeededButUpdatesVersion() { Document<Entity>().With(x => x.Number); Document<OtherEntity>().With(x => x.Number); // add migration for same version and one for other document UseMigrations( new InlineMigration(1, new ChangeDocument<Entity>((serializer, bytes) => bytes)), new InlineMigration(2, new ChangeDocument<OtherEntity>((serializer, bytes) => bytes))); var id = NewId(); var table = configuration.GetDesignFor<Entity>().Table; store.Insert(table, id, new { AwaitsReprojection = false, Discriminator = "Entity", Version = 1, Document = configuration.Serializer.Serialize(new Entity()) }); var counter = new TracingDocumentStoreDecorator(store); new DocumentMigrationRunner(counter).RunSynchronously(); var row = store.Get(table, id); counter.Gets.ShouldBeEmpty(); row[table.VersionColumn].ShouldBe(2); }
public void QueriesInSetsAndUpdatesOneByOne() { Document<Entity>().With(x => x.Number); store.Initialize(); for (int i = 0; i < 200; i++) { store.Insert(new DocumentTable("Entities"), NewId(), new { Discriminator = typeof(Entity).AssemblyQualifiedName, Version = 0, Document = configuration.Serializer.Serialize(new Entity()) }); } // bump the version of the configuration UseMigrations(new InlineMigration(1)); var counter = new TracingDocumentStoreDecorator(store); new DocumentMigrationRunner().Run(counter).Wait(); // 1+2: Entities table => 100 rows // 3: Entities table => 0 rows counter.Queries.Count(x => x.Name == "Entities").ShouldBe(3); // each document is being updated individually counter.Updates.Count.ShouldBe(200); }
public void QueriesInSetsAndUpdatesOneByOne() { Document<Entity>().With(x => x.Number); for (int i = 0; i < 200; i++) { store.Insert(new DocumentTable("Entities"), NewId(), new { Discriminator = "Entity", Version = 0, Document = configuration.Serializer.Serialize(new Entity()) }); } // bump the version of the configuration UseMigrations(new InlineMigration(1)); var counter = new TracingDocumentStoreDecorator(store); new DocumentMigrationRunner(counter).RunSynchronously(); // 3 query for documents below version, first two return 100 rows each, last returns 0 counter.Queries.Count.ShouldBe(3); // each document is being updated individually counter.Updates.Count.ShouldBe(200); }