Пример #1
0
        public void CustomLookupOnCustomUnmanagedEntityConformingRuleResultStringIsCorrect()
        {
            var entity = new EntityMetadata()
            {
                SchemaName  = "foo_MyEntity",
                DisplayName = new Label()
                {
                    UserLocalizedLabel = new LocalizedLabel("My Entity", 1033)
                }
            };

            entity.SetSealedPropertyValue("IsManaged", false);
            entity.SetSealedPropertyValue("IsCustomEntity", true);

            var scope = RuleScope.Lookup;

            var lookupAttr = new LookupAttributeMetadata(LookupFormat.None)
            {
                SchemaName = "foo_MyCustomLookupId"
            };

            lookupAttr.SetSealedPropertyValue("IsCustomAttribute", true);
            lookupAttr.SetSealedPropertyValue("IsManaged", false);

            var attributes = new List <AttributeMetadata> {
                lookupAttr
            };
            var solutionEntity = new SolutionEntity(entity, attributes, true);

            var rule    = new RegexRule(_REGEX_PATTERN, scope);
            var results = rule.Validate(solutionEntity);

            Assert.Equal($"Rule: {rule.Description} Succeeded for entity \"My Entity\" (foo_MyEntity).",
                         results.FormatValidationResult());
        }
Пример #2
0
        public void CustomLookupOnCustomUnmanagedEntityNotConformingRuleValidationMessage()
        {
            var entity = new EntityMetadata()
            {
                SchemaName  = "foo_MyEntity",
                DisplayName = new Label()
                {
                    UserLocalizedLabel = new LocalizedLabel("My Entity", 1033)
                }
            };

            entity.SetSealedPropertyValue("IsManaged", false);
            entity.SetSealedPropertyValue("IsCustomEntity", true);

            var scope = RuleScope.Lookup;

            var lookupAttr = new LookupAttributeMetadata(LookupFormat.None)
            {
                SchemaName = "foo_MyCustomLookup"
            };

            lookupAttr.SetSealedPropertyValue("IsCustomAttribute", true);
            lookupAttr.SetSealedPropertyValue("IsManaged", false);

            var attributes = new List <AttributeMetadata> {
                lookupAttr
            };
            var solutionEntity = new SolutionEntity(entity, attributes, true);

            var rule    = new RegexRule(_REGEX_PATTERN, scope);
            var results = rule.Validate(solutionEntity);

            Assert.Equal($"Rule failed: {rule.Description} Following lookups do not match given pattern: foo_MyCustomLookup.",
                         results.FormatValidationResult());
        }
Пример #3
0
        public void CustomLookupOnCustomUnmanagedEntityConformingRule()
        {
            var entity = new EntityMetadata()
            {
                SchemaName = "foo_MyEntity",
            };

            entity.SetSealedPropertyValue("IsManaged", false);
            entity.SetSealedPropertyValue("IsCustomEntity", true);

            var scope = RuleScope.Lookup;

            var lookupAttr = new LookupAttributeMetadata(LookupFormat.None)
            {
                SchemaName = "foo_MyCustomLookupId"
            };

            lookupAttr.SetSealedPropertyValue("IsCustomAttribute", true);
            lookupAttr.SetSealedPropertyValue("IsManaged", false);

            var attributes = new List <AttributeMetadata> {
                lookupAttr
            };
            var solutionEntity = new SolutionEntity(entity, attributes, true);

            var rule    = new RegexRule(_REGEX_PATTERN, scope);
            var results = rule.Validate(solutionEntity);

            Assert.True(results.Passed);
        }
Пример #4
0
        public void ExcludeEntityFromCheck()
        {
            EntityMetadata entity = new EntityMetadata()
            {
                SchemaName = "foobar_myNotSoMagnificientEntity",
            };

            entity.SetSealedPropertyValue("IsManaged", false);
            entity.SetSealedPropertyValue("IsCustomEntity", true);

            List <AttributeMetadata> attributes = null;

            var isOwnedBySolution = true;

            var validSolutionEntity = new SolutionEntity(entity,
                                                         attributes,
                                                         isOwnedBySolution);

            var regexPattern     = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$";
            var scope            = RuleScope.Entity;
            var excludedEntities = new List <string> {
                "foobar_123",
                "foobar_myNotSoMagnificientEntity",
                "foobar_mySecondNotSoGreatAgainEntity"
            };

            var ruleToTest = new RegexRule(regexPattern, scope,
                                           excludedEntities);

            var results = ruleToTest.Validate(validSolutionEntity);

            Assert.True(results.Passed);
        }
Пример #5
0
        public void ManagedCustomEntityMustBeSkippedTest()
        {
            EntityMetadata entity = new EntityMetadata()
            {
                SchemaName = "new_notconforming",
            };

            entity.SetSealedPropertyValue("IsManaged", true);
            entity.SetSealedPropertyValue("IsCustomEntity", true);

            List <AttributeMetadata> attributes = null;

            var isOwnedBySolution = true;

            var validSolutionEntity = new SolutionEntity(entity,
                                                         attributes,
                                                         isOwnedBySolution);

            var regexPattern = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$";
            var scope        = RuleScope.Entity;

            var ruleToTest = new RegexRule(regexPattern, scope);

            var results = ruleToTest.Validate(validSolutionEntity);

            Assert.True(results.Passed);
        }
Пример #6
0
        public void EntityFirstLetterIsCapitalLetterFailureDescriptionIsCorrectTest()
        {
            EntityMetadata entity = new EntityMetadata()
            {
                SchemaName  = "foobar_myMagnificientEntity",
                DisplayName = new Label()
                {
                    UserLocalizedLabel = new LocalizedLabel("Suurenmoinen entiteetti",
                                                            1035)
                }
            };

            entity.SetSealedPropertyValue("IsManaged", false);
            entity.SetSealedPropertyValue("IsCustomEntity", true);

            List <AttributeMetadata> attributes = null;

            var isOwnedBySolution = true;

            var validSolutionEntity = new SolutionEntity(entity,
                                                         attributes,
                                                         isOwnedBySolution);

            var regexPattern = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$";
            var scope        = RuleScope.Entity;

            var ruleToTest = new RegexRule(regexPattern, scope);

            var results = ruleToTest.Validate(validSolutionEntity);

            Assert.Equal($"Rule failed: {ruleToTest.Description} Entity schema name {entity.SchemaName} doesn't match given pattern \"{regexPattern}\".",
                         results.FormatValidationResult());
        }
Пример #7
0
        public void EnsureEntityFirstLetterIsCapitalLetterFailsTest()
        {
            EntityMetadata entity = new EntityMetadata()
            {
                SchemaName = "foobar_myMagnificientEntity",
            };

            entity.SetSealedPropertyValue("IsManaged", false);
            entity.SetSealedPropertyValue("IsCustomEntity", true);

            List <AttributeMetadata> attributes = null;

            var isOwnedBySolution = true;

            var validSolutionEntity = new SolutionEntity(entity,
                                                         attributes,
                                                         isOwnedBySolution);

            var regexPattern = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$";
            var scope        = RuleScope.Entity;

            var ruleToTest = new RegexRule(regexPattern, scope);

            var results = ruleToTest.Validate(validSolutionEntity);

            Assert.False(results.Passed);
        }
Пример #8
0
        public void CustomAttributesMatchingPatternMustSucceedTest()
        {
            EntityMetadata entity = new EntityMetadata()
            {
                SchemaName = "Account",
            };

            entity.SetSealedPropertyValue("IsManaged", true);
            entity.SetSealedPropertyValue("IsCustomEntity", false);

            var field1Metadata = new StringAttributeMetadata("foo_CustomField");

            field1Metadata.SetSealedPropertyValue("IsManaged", false);
            field1Metadata.SetSealedPropertyValue("IsCustomAttribute", true);

            var attributes = new List <AttributeMetadata> {
                field1Metadata
            };

            var isOwnedBySolution = false;

            var validSolutionEntity = new SolutionEntity(entity,
                                                         attributes,
                                                         isOwnedBySolution);

            var regexPattern = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$";
            var scope        = RuleScope.Attribute;

            var ruleToTest = new RegexRule(regexPattern, scope);

            var results = ruleToTest.Validate(validSolutionEntity);

            Assert.True(results.Passed);
        }
Пример #9
0
        public void UnmanagedAttributesOnOobEntityWithIncorrectNamesFailureDescriptionIsCorrectTest()
        {
            EntityMetadata entity = new EntityMetadata()
            {
                SchemaName  = "Account",
                DisplayName = new Label()
                {
                    UserLocalizedLabel = new LocalizedLabel("Asiakas", 1035)
                }
            };

            entity.SetSealedPropertyValue("IsManaged", true);
            entity.SetSealedPropertyValue("IsCustomEntity", false);

            var field1Metadata = new StringAttributeMetadata("foo_customField");

            field1Metadata.SetSealedPropertyValue("IsManaged", false);
            field1Metadata.SetSealedPropertyValue("IsCustomAttribute", true);

            var field2Metadata = new StringAttributeMetadata("foo_c");

            field2Metadata.SetSealedPropertyValue("IsManaged", false);
            field2Metadata.SetSealedPropertyValue("IsCustomAttribute", true);

            var field3Metadata = new StringAttributeMetadata("foo_CustomField");

            field3Metadata.SetSealedPropertyValue("IsManaged", false);
            field3Metadata.SetSealedPropertyValue("IsCustomAttribute", true);

            var attributes = new List <AttributeMetadata> {
                field1Metadata,
                field2Metadata,
                field3Metadata
            };

            var isOwnedBySolution = false;

            var validSolutionEntity = new SolutionEntity(entity,
                                                         attributes,
                                                         isOwnedBySolution);

            var regexPattern = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$";
            var scope        = RuleScope.Attribute;

            var ruleToTest = new RegexRule(regexPattern, scope);

            var results = ruleToTest.Validate(validSolutionEntity);

            Assert.Equal($"Rule failed: {ruleToTest.Description} " +
                         "Following attributes do not match given pattern: " +
                         "foo_customField, foo_c.",
                         results.FormatValidationResult());
        }
Пример #10
0
        public void ExcludeUnmanagedAttributesWithIncorrectNamesFromValidationTest()
        {
            EntityMetadata entity = new EntityMetadata()
            {
                SchemaName = "Account",
            };

            entity.SetSealedPropertyValue("IsManaged", true);
            entity.SetSealedPropertyValue("IsCustomEntity", false);

            var field1Metadata = new StringAttributeMetadata("foo_customField");

            field1Metadata.SetSealedPropertyValue("IsManaged", false);
            field1Metadata.SetSealedPropertyValue("IsCustomAttribute", true);

            var field2Metadata = new StringAttributeMetadata("foo_c");

            field2Metadata.SetSealedPropertyValue("IsManaged", false);
            field2Metadata.SetSealedPropertyValue("IsCustomAttribute", true);

            var field3Metadata = new StringAttributeMetadata("foo_CustomField");

            field3Metadata.SetSealedPropertyValue("IsManaged", false);
            field3Metadata.SetSealedPropertyValue("IsCustomAttribute", true);

            var attributes = new List <AttributeMetadata> {
                field1Metadata,
                field2Metadata,
                field3Metadata
            };

            var isOwnedBySolution = false;

            var validSolutionEntity = new SolutionEntity(entity,
                                                         attributes,
                                                         isOwnedBySolution);

            var regexPattern       = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$";
            var scope              = RuleScope.Attribute;
            var excludedAttributes = new List <string> {
                "Account.foo_customField",
                "Account.foo_c"
            };

            var ruleToTest = new RegexRule(regexPattern, scope,
                                           excludedAttributes);

            var results = ruleToTest.Validate(validSolutionEntity);

            Assert.True(results.Passed);
        }
Пример #11
0
        public void ExcludedLookupsAreCheckedOnCustomUnmanagedEntity()
        {
            var entity = new EntityMetadata()
            {
                SchemaName = "foo_myEntity",
            };

            entity.SetSealedPropertyValue("IsManaged", false);
            entity.SetSealedPropertyValue("IsCustomEntity", true);

            var scope = RuleScope.Lookup;

            var lookupAttr = new LookupAttributeMetadata()
            {
                SchemaName = "foo_LookupFieldId2"
            };

            lookupAttr.SetSealedPropertyValue("IsCustomAttribute", true);
            lookupAttr.SetSealedPropertyValue("IsManaged", false);

            var primaryKeyAttr = new LookupAttributeMetadata()
            {
                SchemaName = "foo_MyEntityId"
            };

            primaryKeyAttr.SetSealedPropertyValue("IsCustomAttribute", true);
            primaryKeyAttr.SetSealedPropertyValue("IsManaged", false);

            var attributes = new List <AttributeMetadata> {
                lookupAttr,
                primaryKeyAttr
            };
            var solutionEntity = new SolutionEntity(entity, attributes, true);

            var excludedSchemaNames = new string[] { "foo_myEntity.foo_LookupFieldId2" };

            var rule    = new RegexRule(_REGEX_PATTERN, scope, excludedSchemaNames);
            var results = rule.Validate(solutionEntity);

            Assert.True(results.Passed);
        }
Пример #12
0
        public void OnlyLookupsAreCheckedOnCustomUnmanagedEntity()
        {
            var entity = new EntityMetadata()
            {
                SchemaName = "foo_myEntity",
            };

            entity.SetSealedPropertyValue("IsManaged", false);
            entity.SetSealedPropertyValue("IsCustomEntity", true);

            var scope = RuleScope.Lookup;

            var stringAttr = new StringAttributeMetadata()
            {
                SchemaName = "foo_StrField"
            };

            stringAttr.SetSealedPropertyValue("IsCustomAttribute", true);
            stringAttr.SetSealedPropertyValue("IsManaged", false);

            var primaryKeyAttr = new UniqueIdentifierAttributeMetadata()
            {
                SchemaName = "foo_myEntityId"
            };

            primaryKeyAttr.SetSealedPropertyValue("IsCustomAttribute", true);
            primaryKeyAttr.SetSealedPropertyValue("IsManaged", false);

            var attributes = new List <AttributeMetadata> {
                stringAttr,
                primaryKeyAttr
            };
            var solutionEntity = new SolutionEntity(entity, attributes, true);

            var rule    = new RegexRule(_REGEX_PATTERN, scope);
            var results = rule.Validate(solutionEntity);

            Assert.True(results.Passed);
        }