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

            using (var store = GetDocumentStore())
            {
                InitialiseWithPeople(store, new List <Person>()
                {
                    new Person {
                        FirstName = "Animal", LastName = "Man"
                    },
                    new Person {
                        FirstName = "Aqua", LastName = "Baby"
                    },
                    new Person {
                        FirstName = "Atom", LastName = "Girl"
                    },
                    new Person {
                        FirstName = "Alex", LastName = "Mercer"
                    },
                    new Person {
                        FirstName = "Killer", LastName = "Croc"
                    }
                });
                var migration = new AddFullName();
                migration.Setup(store, loggerMock.Object);

                migration.Up();
            }

            loggerMock.Verify(logger => logger.LogInformation("Updated {0} documents", 2), Times.Exactly(2), "Informational message should indicate how many documents were updated.");
            loggerMock.Verify(logger => logger.LogInformation("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 = GetDocumentStore())
            {
                var scarletSpider = InitialiseWithPerson(store, "Scarlet", "Spider");

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

                migration.Up();
            }

            loggerMock.Verify(logger => logger.LogInformation("Updated {0} documents", 1), "Informational message should indicate how many documents were updated.");
        }
Пример #3
0
        public void Can_migrate_up()
        {
            using var store = GetDocumentStore();
            var professorZoom = InitialiseWithPerson(store, "Professor", "Zoom");

            var migration = new AddFullName();

            migration.Setup(store, new MigrationOptions(), logger);

            migration.Up();

            using var session = store.OpenSession();
            var loaded = session.Load <Person>(professorZoom.Id);

            loaded.FullName.Should().Be("Professor Zoom");
        }
Пример #4
0
        public void Can_migrate_down()
        {
            using var store = GetDocumentStore();
            var ladyDeathstrike = InitialiseWithPerson(store, "Lady", "Deathstrike");

            var migration = new AddFullName();

            migration.Setup(store, new MigrationOptions(), logger);

            migration.Up();
            WaitForIndexing(store);

            migration.Down();
            WaitForIndexing(store);

            using var session = store.OpenSession();
            var loaded = session.Load <Person>(ladyDeathstrike.Id);

            loaded.FullName.Should().Be(null);
        }