コード例 #1
0
        public void TestUnsafeMultivalue()
        {
            SafetyRule rule = new SafetyRule();

            rule.Pattern           = @"^fimtest\+.+@.+\..+$";
            rule.AcmaSchemaMapping = ActiveConfig.DB.Mappings.First(t => t.Attribute.Name == "mailAlternateAddresses" && t.ObjectClass.Name == "person");
            rule.NullAllowed       = false;

            AttributeValues values = new InternalAttributeValues(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object> {
                "*****@*****.**", "*****@*****.**"
            });

            try
            {
                rule.Validate(values);
                Assert.Fail("The rule did not fail the validation attempt");
            }
            catch (SafetyRuleViolationException)
            {
            }

            values = new InternalAttributeValues(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object> {
                "*****@*****.**", "*****@*****.**"
            });
            rule.Validate(values);
        }
コード例 #2
0
        public void TestUnsafeNullValue()
        {
            SafetyRule rule = new SafetyRule();

            rule.Pattern           = @"^fimtest\+.+@.+\..+$";
            rule.AcmaSchemaMapping = ActiveConfig.DB.Mappings.First(t => t.Attribute.Name == "mail" && t.ObjectClass.Name == "person");
            rule.NullAllowed       = false;

            AttributeValue value = new AttributeValue(ActiveConfig.DB.GetAttribute("mail"), null);

            try
            {
                rule.Validate(value);
                Assert.Fail("The rule did not fail the validation attempt");
            }
            catch (SafetyRuleViolationException)
            {
            }

            value = new AttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");
            rule.Validate(value);
        }