public static async Task AnalyseTables_GivenTableWithNoRelations_ProducesMessages()
        {
            var rule = new OrphanedTableRule(RuleLevel.Error);

            var table = new RelationalDatabaseTable(
                "test",
                new List <IDatabaseColumn>(),
                null,
                Array.Empty <IDatabaseKey>(),
                Array.Empty <IDatabaseRelationalKey>(),
                Array.Empty <IDatabaseRelationalKey>(),
                Array.Empty <IDatabaseIndex>(),
                Array.Empty <IDatabaseCheckConstraint>(),
                Array.Empty <IDatabaseTrigger>()
                );
            var tables = new[] { table };

            var hasMessages = await rule.AnalyseTables(tables).AnyAsync().ConfigureAwait(false);

            Assert.That(hasMessages, Is.True);
        }
        public static async Task AnalyseTables_GivenTableWithChildKeys_ProducesNoMessages()
        {
            var rule = new OrphanedTableRule(RuleLevel.Error);

            var childKey = new DatabaseRelationalKey(
                "child_table",
                new DatabaseKey(
                    Option <Identifier> .Some("child_key"),
                    DatabaseKeyType.Foreign,
                    new[] { Mock.Of <IDatabaseColumn>() },
                    true
                    ),
                "parent_table",
                new DatabaseKey(
                    Option <Identifier> .Some("parent_key"),
                    DatabaseKeyType.Primary,
                    new[] { Mock.Of <IDatabaseColumn>() },
                    true
                    ),
                ReferentialAction.NoAction,
                ReferentialAction.NoAction
                );
            var parentTable = new RelationalDatabaseTable(
                "test",
                new List <IDatabaseColumn>(),
                null,
                Array.Empty <IDatabaseKey>(),
                Array.Empty <IDatabaseRelationalKey>(),
                new[] { childKey },
                Array.Empty <IDatabaseIndex>(),
                Array.Empty <IDatabaseCheckConstraint>(),
                Array.Empty <IDatabaseTrigger>()
                );
            var tables = new[] { parentTable };

            var hasMessages = await rule.AnalyseTables(tables).AnyAsync().ConfigureAwait(false);

            Assert.That(hasMessages, Is.False);
        }
        public static void AnalyseTables_GivenNullTables_ThrowsArgumentNullException()
        {
            var rule = new OrphanedTableRule(RuleLevel.Error);

            Assert.That(() => rule.AnalyseTables(null), Throws.ArgumentNullException);
        }