Пример #1
0
        public void Logger_WriteInformation_is_called_per_batch_when_altering_collection()
        {
            var loggerMock = new Mock <ILogger>();

            using (var store = NewDocumentStore())
            {
                InitialiseWithPeople(store, new List <Person1>()
                {
                    new Person1 {
                        Name = "Sean Kearon"
                    },
                    new Person1 {
                        Name = "Jared M. Smith"
                    },
                    new Person1 {
                        Name = "Michael Owen"
                    },
                    new Person1 {
                        Name = "Jonathan Skelton"
                    },
                    new Person1 {
                        Name = "Matt King"
                    }
                });
                var migration = new AlterCollectionMigration();
                migration.Setup(store, loggerMock.Object);

                migration.Up();
            }

            loggerMock.Verify(logger => logger.WriteInformation("Updated {0} documents", 2), Times.Exactly(2), "Informational message should indicate how many documents were updated.");
            loggerMock.Verify(logger => logger.WriteInformation("Updated {0} documents", 1), Times.Once, "Informational message should indicate how many documents were updated.");
        }
Пример #2
0
        public void Logger_WriteInformation_is_called_when_altering_collection()
        {
            var loggerMock = new Mock <ILogger>();

            using (var store = NewDocumentStore())
            {
                InitialiseWithPerson(store, "Sean Kearon");

                var migration = new AlterCollectionMigration();
                migration.Setup(store, loggerMock.Object);

                migration.Up();
            }

            loggerMock.Verify(logger => logger.WriteInformation("Updated {0} documents", 1), "Informational message should indicate how many documents were updated.");
        }
Пример #3
0
        public void Can_add_additional_commands_as_part_of_migration()
        {
            using (var store = NewDocumentStore())
            {
                InitialiseWithPerson(store, "Sean Kearon");

                var migration = new AlterCollectionMigration();
                migration.Setup(store, new NullLogger());

                migration.Up();

                using (var session = store.OpenSession())
                {
                    var foobaz = session.Load <FooBaz>(1);
                    foobaz.Bar.Should().BeEquivalentTo("loaded");
                }
            }
        }
Пример #4
0
        public void Can_migrate_up_to_new_clr_type()
        {
            using (var store = NewDocumentStore())
            {
                InitialiseWithPerson(store, "Sean Kearon");

                var migration = new AlterCollectionMigration();
                migration.Setup(store, new NullLogger());

                migration.Up();
                using (var session = store.OpenSession())
                {
                    var customer = session.Load <Person2>("People/1");
                    customer.FirstName.Should().Be("Sean");
                    customer.LastName.Should().Be("Kearon");
                }
            }
        }
Пример #5
0
        public void Can_add_additional_commands_as_part_of_migration()
        {
            using (var store = NewDocumentStore())
            {
                InitialiseWithPerson(store, "Sean Kearon");

                var migration = new AlterCollectionMigration();
                migration.Setup(store);

                migration.Up();

                using (var session = store.OpenSession())
                {
                    var foobaz = session.Load<FooBaz>(1);
                    foobaz.Bar.Should().BeEquivalentTo("loaded");
                }
            }
        }
Пример #6
0
        public void Can_migrate_up_to_new_clr_type()
        {
            using (var store = NewDocumentStore())
            {
                InitialiseWithPerson(store, "Sean Kearon");

                var migration = new AlterCollectionMigration();
                migration.Setup(store);

                migration.Up();
                using (var session = store.OpenSession())
                {
                    var customer = session.Load<Person2>("People/1");
                    customer.FirstName.Should().Be("Sean");
                    customer.LastName.Should().Be("Kearon");
                }
            }
        }
Пример #7
0
        public void Can_migrate_down_from_new_clr_type()
        {
            using (var store = NewDocumentStore())
            {
                InitialiseWithPerson(store, "Sean Kearon");

                var migration = new AlterCollectionMigration();
                migration.Setup(store, new NullLogger());

                migration.Up();
                WaitForIndexing(store);

                migration.Down();
                WaitForIndexing(store);

                using (var session = store.OpenSession())
                {
                    var customer = session.Load <Person1>("People/1");
                    customer.Name.Should().Be("Sean Kearon");
                }
            }
        }
Пример #8
0
        public void Can_migrate_down_from_new_clr_type()
        {
            using (var store = NewDocumentStore())
            {
                InitialiseWithPerson(store, "Sean Kearon");

                var migration = new AlterCollectionMigration();
                migration.Setup(store);

                migration.Up();
                WaitForIndexing(store);

                migration.Down();
                WaitForIndexing(store);

                using (var session = store.OpenSession())
                {
                    var customer = session.Load<Person1>("People/1");
                    customer.Name.Should().Be("Sean Kearon");
                }
            }
        }