public static bool IsFeatureSupported(this IExclusiveIntegrationTestMigration migration, IDatabase db)
        {
            if (migration.PlatformsNotSupportingFeatureUnderTest.Contains(db.Context.ProviderMetadata.Platform))
            {
                return(false);
            }
            IVersionConstrainedExclusiveIntegrationTestMigration constrainedMigration = migration as IVersionConstrainedExclusiveIntegrationTestMigration;

            if (constrainedMigration != null)
            {
                return(db.Context.ProviderMetadata.MajorVersion >= constrainedMigration.MinimumVersionSupportingFeatureUnderTest(db.Context.ProviderMetadata.Platform).MajorVersion);
            }
            return(true);
        }
Beispiel #2
0
        protected void VerifyResultsOfAllMigrations()
        {
            // assert all tables have been created with the expected content
            foreach (IIntegrationTestMigration migration in Migrations.OfType <IIntegrationTestMigration>())
            {
                IExclusiveIntegrationTestMigration exclusiveIntegrationTestMigration = migration as IExclusiveIntegrationTestMigration;
                if (exclusiveIntegrationTestMigration != null && exclusiveIntegrationTestMigration.PlatformsNotSupportingFeatureUnderTest.Contains(DbPlatform.Platform))
                {
                    continue; // do not check result of an unsupported migration
                }
                IVersionConstrainedExclusiveIntegrationTestMigration constrainedMigration = migration as IVersionConstrainedExclusiveIntegrationTestMigration;
                if (constrainedMigration != null && DbPlatform.MajorVersion < constrainedMigration.MinimumVersionSupportingFeatureUnderTest(DbPlatform.Platform).MajorVersion)
                {
                    continue; // do not check result of an unsupported migration
                }

                foreach (ExpectedTable expectedTable in migration.Tables)
                {
                    DataTable table = GetTable(expectedTable.FullName);

                    Assert.IsNotNull(table, string.Format(CultureInfo.CurrentCulture, "The table '{0}' was not created.", expectedTable.FullName));
                    Assert.AreEqual(expectedTable.Columns.Count, table.Columns.Count, "The actual number of columns of the table '{0}' is wrong.", table.TableName);
                    Assert.AreEqual(expectedTable.Count, table.Rows.Count, "The actual number of rows of the table '{0}' is wrong.", table.TableName);
                    for (int column = 0; column < expectedTable.Columns.Count; column++)
                    {
                        // check column name
                        Assert.AreEqual(expectedTable.Columns[column], table.Columns[column].ColumnName,
                                        string.Format(CultureInfo.CurrentCulture, "A column name of table '{0}' is wrong.", expectedTable.FullName));

                        // check content
                        for (int row = 0; row < expectedTable.Count; row++)
                        {
                            object expectedValue          = expectedTable.Value(row, column);
                            object actualValue            = table.Rows[row][column];
                            Func <object, bool> evalValue = expectedValue as Func <object, bool>;
                            if (evalValue != null)
                            {
                                Assert.IsTrue(evalValue(actualValue), string.Format(CultureInfo.CurrentCulture, "In '{0}', the actual value of cell {1}/{2} of table '{3}' is wrong (the custom handler returned false).",
                                                                                    migration.GetType().Name,
                                                                                    row,
                                                                                    column,
                                                                                    expectedTable.FullName));
                            }
                            else
                            {
                                Assert.AreEqual(expectedValue, actualValue, string.Format(CultureInfo.CurrentCulture, "In '{0}', the actual value of cell {1}/{2} of table '{3}' is wrong.",
                                                                                          migration.GetType().Name,
                                                                                          row,
                                                                                          column,
                                                                                          expectedTable.FullName));
                            }
                        }
                    }
                }
            }

            // assert Versioning table has necessary entries
            DataTable versioningTable = GetTable(_options.VersioningTable);

            Assert.AreEqual(Migrations.Count, versioningTable.Rows.Count, "The versioning table has a wrong number of entries.");
            DataRow[] versioningRows = versioningTable.Select(null, BootstrapMigration.TimestampColumnName); // order by Timestamp
            for (int i = 0; i < Migrations.Count; i++)
            {
                Assert.AreEqual(Timestamps[i], versioningRows[i][0], string.Format(CultureInfo.CurrentCulture, "The timestamp of Migration{0} is wrong.", i + 1));
            }

            // check Module and Tag of Migration2 (special case)
            Assert.AreEqual(Migration2.Module, versioningRows[1][1], "The module of Migration2 is wrong.");
            Assert.AreEqual(Migration2.Tag, versioningRows[1][2], "The tag of Migration2 is wrong.");
        }