コード例 #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 async Task GetAppliedMigrations_works(bool async)
    {
        var migrations = new[] { "00000000000001_One", "00000000000002_Two" };

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

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

        Assert.Equal(
            migrations,
            async
                ? await context.Database.GetAppliedMigrationsAsync()
                : context.Database.GetAppliedMigrations());
    }