예제 #1
0
        public async Task GetPendingMigrations_works(bool async)
        {
            var migrations = new[] { "00000000000001_One", "00000000000002_Two", "00000000000003_Three" };

            var appliedMigrations = new[] { "00000000000001_One", "00000000000002_Two" };

            var migrationsAssembly = new FakeIMigrationsAssembly {
                Migrations = migrations.ToDictionary(x => x, x => default(TypeInfo))
            };

            var repository = new FakeHistoryRepository
            {
                AppliedMigrations = appliedMigrations.Select(id => new HistoryRow(id, "1.1.0")).ToList()
            };

            var context = RelationalTestHelpers.Instance.CreateContext(
                new ServiceCollection()
                .AddSingleton <IHistoryRepository>(repository)
                .AddSingleton <IMigrationsAssembly>(migrationsAssembly));

            Assert.Equal(
                new[] { "00000000000003_Three" },
                async
                    ? await context.Database.GetPendingMigrationsAsync()
                    : context.Database.GetPendingMigrations());
        }
예제 #2
0
        public void GetMigrations_works()
        {
            var migrations = new[] { "00000000000001_One", "00000000000002_Two", "00000000000003_Three" };

            var migrationsAssembly = new FakeIMigrationsAssembly {
                Migrations = migrations.ToDictionary(x => x, x => default(TypeInfo))
            };

            var db = RelationalTestHelpers.Instance.CreateContext(
                new ServiceCollection().AddSingleton <IMigrationsAssembly>(migrationsAssembly));

            Assert.Equal(migrations, db.Database.GetMigrations());
        }