示例#1
0
        public static void GetRules_GivenDefaultProvider_ReturnsNonEmptySet()
        {
            var dbConnection = Mock.Of <IDbConnectionFactory>();
            var dialect      = Mock.Of <IDatabaseDialect>();
            var connection   = new SchematicConnection(dbConnection, dialect);

            var ruleProvider = new CompositeRuleProvider(new[] { new DefaultRuleProvider() });
            var rules        = ruleProvider.GetRules(connection, RuleLevel.Error);

            Assert.That(rules, Is.Not.Empty);
        }
示例#2
0
        public static void GetRules_GivenNoProviders_ReturnsEmptySet()
        {
            var dbConnection = Mock.Of <IDbConnectionFactory>();
            var dialect      = Mock.Of <IDatabaseDialect>();
            var connection   = new SchematicConnection(dbConnection, dialect);

            var ruleProvider = new CompositeRuleProvider(Array.Empty <IRuleProvider>());
            var rules        = ruleProvider.GetRules(connection, RuleLevel.Error);

            Assert.That(rules, Is.Empty);
        }
示例#3
0
        public static void GetRules_GivenMultipleProviders_ReturnsExpectedRuleCount()
        {
            var dbConnection = Mock.Of <IDbConnectionFactory>();
            var dialect      = Mock.Of <IDatabaseDialect>();
            var connection   = new SchematicConnection(dbConnection, dialect);

            var defaultProvider = new DefaultRuleProvider();

            var ruleProvider  = new CompositeRuleProvider(new[] { defaultProvider, defaultProvider });
            var defaultRules  = defaultProvider.GetRules(connection, RuleLevel.Error).ToList();
            var expectedCount = defaultRules.Count * 2;

            var compositeRules = ruleProvider.GetRules(connection, RuleLevel.Error);

            Assert.That(compositeRules, Has.Exactly(expectedCount).Items);
        }
示例#4
0
        public static void GetRules_GivenInvalidRuleLevel_ThrowsArgumentException()
        {
            var ruleProvider = new CompositeRuleProvider(Array.Empty <IRuleProvider>());

            Assert.That(() => ruleProvider.GetRules(Mock.Of <ISchematicConnection>(), (RuleLevel)555), Throws.ArgumentException);
        }
示例#5
0
        public static void GetRules_GivenNullConnection_ThrowsArgumentNullException()
        {
            var ruleProvider = new CompositeRuleProvider(Array.Empty <IRuleProvider>());

            Assert.That(() => ruleProvider.GetRules(null, RuleLevel.Error), Throws.ArgumentNullException);
        }