コード例 #1
0
        public QaSchemaFieldAliases(
            [Doc(nameof(DocStrings.QaSchemaFieldAliases_table))][NotNull]
            ITable table,
            [Doc(nameof(DocStrings.QaSchemaFieldAliases_maximumLength))]
            int maximumLength,
            [Doc(nameof(DocStrings.QaSchemaFieldAliases_expectedCase))]
            ExpectedCase expectedCase,
            [Doc(nameof(DocStrings.QaSchemaFieldAliases_requireUniqueAliasNames))]
            bool requireUniqueAliasNames,
            [Doc(nameof(DocStrings.QaSchemaFieldAliases_allowCustomSystemFieldAlias))]
            bool
            allowCustomSystemFieldAlias,
            [Doc(nameof(DocStrings.QaSchemaFieldAliases_expectedDifference))]
            ExpectedStringDifference
            expectedDifference)
            : base(table)
        {
            Assert.ArgumentNotNull(table, nameof(table));

            _table                       = table;
            _maximumLength               = maximumLength;
            _expectedCase                = expectedCase;
            _requireUniqueAliasNames     = requireUniqueAliasNames;
            _allowCustomSystemFieldAlias = allowCustomSystemFieldAlias;
            _expectedDifference          = expectedDifference;
        }
コード例 #2
0
        private static string GetDifferenceError([NotNull] string fieldName,
                                                 [NotNull] string aliasName,
                                                 ExpectedStringDifference expectedDifference,
                                                 [CanBeNull] out IssueCode issueCode)
        {
            switch (expectedDifference)
            {
            case ExpectedStringDifference.Any:
                issueCode = null;
                return(null);

            case ExpectedStringDifference.CaseSensitiveDifference:
                if (!string.Equals(fieldName, aliasName))
                {
                    // difference in case only is valid
                    issueCode = null;
                    return(null);
                }

                issueCode = Codes[Code.EqualsFieldName];
                return(string.Format(
                           LocalizableStrings.QaSchemaFieldAliases_EqualsFieldName,
                           aliasName, fieldName));

            case ExpectedStringDifference.CaseInsensitiveDifference:
                if (string.Equals(fieldName, aliasName,
                                  StringComparison.InvariantCultureIgnoreCase))
                {
                    string description;
                    if (string.Equals(fieldName, aliasName))
                    {
                        // equal also in case
                        description = LocalizableStrings.QaSchemaFieldAliases_EqualsFieldName;
                        issueCode   = Codes[Code.EqualsFieldName];
                    }
                    else
                    {
                        // differs in case only (still not correct, but different description/code)
                        description = LocalizableStrings
                                      .QaSchemaFieldAliases_EqualsFieldNameExceptCase;
                        issueCode = Codes[Code.EqualsFieldName_ExceptCase];
                    }

                    return(string.Format(description, aliasName, fieldName));
                }

                issueCode = null;
                return(null);

            default:
                throw new ArgumentOutOfRangeException(nameof(expectedDifference),
                                                      expectedDifference,
                                                      @"Unsupported expected difference");
            }
        }
コード例 #3
0
        private static IList <QaError> GetErrors([NotNull] string tableName,
                                                 int maximumLength,
                                                 ExpectedCase expectedCase,
                                                 bool requireUnique,
                                                 bool allowCustomSystemFieldAlias,
                                                 ExpectedStringDifference
                                                 expectedStringDifference)
        {
            var    locator = TestDataUtils.GetTestDataLocator();
            string path    = locator.GetPath("QaSchemaTests.mdb");

            IFeatureWorkspace workspace = WorkspaceUtils.OpenPgdbFeatureWorkspace(path);

            ITable table = workspace.OpenTable(tableName);
            var    test  = new QaSchemaFieldAliases(table, maximumLength, expectedCase,
                                                    requireUnique, allowCustomSystemFieldAlias,
                                                    expectedStringDifference);

            var runner = new QaTestRunner(test);

            runner.Execute();

            return(runner.Errors);
        }