Beispiel #1
0
        public async Task <RuleCheckResult> CheckRuleAsync(IWordDocument document)
        {
            using var webClient = new HeadWebClient();

            var invalidUris = new List <Uri>();

            foreach (var link in document.ExternalHyperLinks)
            {
                try
                {
                    await webClient.DownloadDataTaskAsync(link.Uri);
                }
                catch (WebException)
                {
                    invalidUris.Add(link.Uri);
                }
            }

            if (!invalidUris.Any())
            {
                return(RuleCheckResult.CreatePassed(RuleName));
            }

            var missingUrls = string.Join(", ", invalidUris.Select(f => f.AbsoluteUri));

            return(RuleCheckResult.CreateFailure(RuleName, missingUrls));
        }
        public async Task <RuleCheckResult> CheckElementsAsync(string ruleName, string captionPrefix, IReadOnlyCollection <IElementWithCaption> elementsWithCaption)
        {
            return(await Task.Run(
                       () =>
            {
                var details = new List <string>();

                for (var i = 1; i <= elementsWithCaption.Count; i++)
                {
                    var expectedPrefix = $"{captionPrefix} {i}: ";
                    var actualText = elementsWithCaption.ElementAt(i - 1).CaptionText;

                    if (!actualText.StartsWith(expectedPrefix, StringComparison.Ordinal))
                    {
                        details.Add($"Expected {actualText} to start with {expectedPrefix}");
                    }
                }

                if (details.Any())
                {
                    return new RuleCheckResult(false, ruleName, $"Found {details.Count} wrong element sortings", new RuleCheckResultDetails(details));
                }

                return RuleCheckResult.CreatePassed(ruleName);
            }));
        }
Beispiel #3
0
        public Task <RuleCheckResult> CheckRuleAsync(IWordDocument document)
        {
            var shapeDescNotBelow = document
                                    .Shapes
                                    .Where(f => f.Description.Position != Position.Below)
                                    .ToList();

            if (shapeDescNotBelow.Any())
            {
                var str = string.Join(
                    ", ",
                    shapeDescNotBelow.Select(
                        f =>
                {
                    var plainDesc = f.Description.PlainDescription;

                    if (string.IsNullOrEmpty(plainDesc))
                    {
                        plainDesc = NoDescription;
                    }

                    return(plainDesc);
                }));

                return(Task.FromResult(RuleCheckResult.CreateFailure(RuleName, str)));
            }

            return(Task.FromResult(RuleCheckResult.CreatePassed(RuleName)));
        }
        public IEnumerable <RuleCheckResult> ChecksWhetherAReferencedDeprecatableThingIsDeprecated(Thing thing)
        {
            var referencerRule = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            if (!referencerRule.IsDeprecated)
            {
                if (referencerRule.ReferencingCategory.IsDeprecated)
                {
                    var result = new RuleCheckResult(thing, rule.Id,
                                                     $"The referenced Category {referencerRule.ReferencingCategory.Iid}:{referencerRule.ReferencingCategory.ShortName} of ReferencerRule.ReferencingCategory is deprecated",
                                                     SeverityKind.Warning);
                    results.Add(result);
                }

                foreach (var category in referencerRule.ReferencedCategory)
                {
                    if (category.IsDeprecated)
                    {
                        var result = new RuleCheckResult(thing, rule.Id,
                                                         $"The referenced Category {category.Iid}:{category.ShortName} in ReferencerRule.ReferencedCategory is deprecated",
                                                         SeverityKind.Warning);
                        results.Add(result);
                    }
                }
            }

            return(results);
        }
        public IEnumerable <RuleCheckResult> ChecksWhetherAReferencedDeprecatableThingIsDeprecated(Thing thing)
        {
            var ownedThing = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            var deprecatableThing = thing as IDeprecatableThing;

            if (deprecatableThing != null && !deprecatableThing.IsDeprecated)
            {
                if (ownedThing.Owner.IsDeprecated)
                {
                    var result = new RuleCheckResult(thing, rule.Id,
                                                     $"The referenced DomainOfExpertise {ownedThing.Owner.Iid}:{ownedThing.Owner.ShortName} of IOwnedThing.Owner is deprecated",
                                                     SeverityKind.Warning);
                    results.Add(result);
                }
            }
            else
            {
                if (ownedThing.Owner.IsDeprecated)
                {
                    var result = new RuleCheckResult(thing, rule.Id,
                                                     $"The referenced DomainOfExpertise {ownedThing.Owner.Iid}:{ownedThing.Owner.ShortName} of IOwnedThing.Owner is deprecated",
                                                     SeverityKind.Warning);
                    results.Add(result);
                }
            }

            return(results);
        }
Beispiel #6
0
        public async Task <RuleCheckResult> CheckRuleAsync(WordDocument wordDocument)
        {
            return(await Task.Run(
                       () =>
            {
                var forbiddenCounts = new List <Tuple <int, string> >();
                var forbiddenWords = ForbiddenWords.CreateDefault();

                foreach (var forbiddenWord in forbiddenWords.Words)
                {
                    var foundForbiddenWords = wordDocument
                                              .Words
                                              .Where(word => word.Text.ToUpper(CultureInfo.InvariantCulture) == forbiddenWord.ToUpper(CultureInfo.InvariantCulture))
                                              .ToList();

                    if (foundForbiddenWords.Any())
                    {
                        forbiddenCounts.Add(new Tuple <int, string>(foundForbiddenWords.Count, forbiddenWord));
                    }
                }

                if (forbiddenCounts.Any())
                {
                    var overviewMessage = $"Found {forbiddenCounts.Count} forbidden Words.";
                    var sorted = forbiddenCounts
                                 .OrderByDescending(w => w.Item1)
                                 .Select(w => $"{w.Item1}: {w.Item2}")
                                 .ToList();

                    return new RuleCheckResult(false, RuleName, overviewMessage, new RuleCheckResultDetails(sorted));
                }

                return RuleCheckResult.CreatePassed(RuleName);
            }));
        }
        public async Task <RuleCheckResult> CheckRuleAsync(WordDocument wordDocument)
        {
            return(await Task.Run(
                       () =>
            {
                var shapesWithExternalLink = wordDocument.Shapes.Where(f => f.Caption.Entries.Any(e => e.CharacterRepresentation.Contains("[PIC"))).ToList();

                var details = new List <string>();

                for (var i = 1; i <= shapesWithExternalLink.Count; i++)
                {
                    var expectedPicLink = $"[PIC{i}]";
                    var currentItem = shapesWithExternalLink[i - 1];
                    if (!currentItem.Caption.Entries.First().CharacterRepresentation.EndsWith(expectedPicLink, StringComparison.Ordinal))
                    {
                        details.Add($"Expected {currentItem.Caption.Entries.First().CharacterRepresentation} to end with ${expectedPicLink}");
                    }
                }

                if (details.Any())
                {
                    return new RuleCheckResult(false, RuleName, $"Found {details.Count} elements with invalid external link", new RuleCheckResultDetails(details));
                }

                return RuleCheckResult.CreatePassed(RuleName);
            }));
        }
        public IEnumerable <RuleCheckResult> ChecksWhetherAReferencedDeprecatableThingIsDeprecated(Thing thing)
        {
            var personRole = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            if (personRole.IsDeprecated)
            {
                return(results);
            }

            foreach (var personPermission in personRole.PersonPermission)
            {
                if (personPermission.IsDeprecated)
                {
                    var result = new RuleCheckResult(thing, rule.Id,
                                                     $"The referenced PersonPermission {personPermission.Iid}:{personPermission.ObjectClass} in PersonRole.PersonPermission is deprecated",
                                                     SeverityKind.Warning);
                    results.Add(result);
                }
            }

            return(results);
        }
Beispiel #9
0
        public async Task <RuleCheckResult> CheckRuleAsync(WordDocument wordDocument)
        {
            return(await Task.Run(
                       () =>
            {
                var glossaryTable = wordDocument.Tables.Single(f => f.Caption.Entries.Any(e => e.CharacterRepresentation.EndsWith("Glossar", StringComparison.Ordinal)));
                var glossaryWords = glossaryTable.Cells.Where(f => f.ColumnIndex == 1 && f.RowIndex > 1).Select(f => f.Value).ToList();

                var wordsNotFound = new List <string>();
                var wordsCombined = string.Join(" ", wordDocument.Select(word => word.Text));

                foreach (var glossaryWord in glossaryWords)
                {
                    var occurrences = FindOccurrences(wordsCombined, glossaryWord);
                    if (occurrences <= 1)
                    {
                        wordsNotFound.Add(glossaryWord);
                    }
                }

                if (wordsNotFound.Any())
                {
                    var overviewMessage = $"Found {wordsNotFound.Count} unused Glossary Words.";
                    return new RuleCheckResult(false, RuleName, overviewMessage, new RuleCheckResultDetails(wordsNotFound));
                }

                return RuleCheckResult.CreatePassed(RuleName);
            }));
        }
Beispiel #10
0
        public IEnumerable <RuleCheckResult> ChecksWhetherAReferencedDeprecatableThingIsDeprecated(Thing thing)
        {
            var referenceSource = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            if (referenceSource.IsDeprecated)
            {
                return(results);
            }

            if (referenceSource.Publisher.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id,
                                                 $"The referenced Organization {referenceSource.Publisher.Iid}:{referenceSource.Publisher.ShortName} of ReferenceSource.Publisher is deprecated",
                                                 SeverityKind.Warning);
                results.Add(result);
            }

            if (referenceSource.PublishedIn.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id,
                                                 $"The referenced ReferenceSource {referenceSource.PublishedIn.Iid}:{referenceSource.PublishedIn.ShortName} of ReferenceSource.PublishedIn is deprecated",
                                                 SeverityKind.Warning);
                results.Add(result);
            }

            return(results);
        }
Beispiel #11
0
        public IEnumerable <RuleCheckResult> ChecksWhetherAReferencedDeprecatableThingIsDeprecated(Thing thing)
        {
            var quantityKind = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            if (quantityKind.IsDeprecated)
            {
                return(results);
            }

            foreach (var measurementScale in quantityKind.PossibleScale)
            {
                if (measurementScale.IsDeprecated)
                {
                    var result = new RuleCheckResult(thing, rule.Id,
                                                     $"The referenced MeasurementScale {measurementScale.Iid}:{measurementScale.ShortName} in QuantityKind.PossibleScale is deprecated",
                                                     SeverityKind.Warning);
                    results.Add(result);
                }
            }

            if (quantityKind.DefaultScale.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id,
                                                 $"The referenced MeasurementScale {quantityKind.DefaultScale.Iid}:{quantityKind.DefaultScale.ShortName} of QuantityKind.DefaultScale is deprecated",
                                                 SeverityKind.Warning);
                results.Add(result);
            }

            return(results);
        }
Beispiel #12
0
        public IEnumerable <RuleCheckResult> CheckWhetherReferencedMeasurementScaleInChainOfRdls(Thing thing)
        {
            var quantityKind = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            var referenceDataLibrary = (ReferenceDataLibrary)thing.GetContainerOfType(typeof(ReferenceDataLibrary));

            foreach (var measurementScale in quantityKind.PossibleScale)
            {
                if (!referenceDataLibrary.IsMeasurementScaleInChainOfRdls(measurementScale))
                {
                    var result = new RuleCheckResult(thing, rule.Id, $"The referenced MeasurementScale {measurementScale.Iid}:{measurementScale.ShortName} in QuantityKind.PossibleScale is not in the chain of Reference Data Libraries", SeverityKind.Error);
                    results.Add(result);
                }
            }

            if (!referenceDataLibrary.IsMeasurementScaleInChainOfRdls(quantityKind.DefaultScale))
            {
                var result = new RuleCheckResult(thing, rule.Id, $"The referenced MeasurementScale {quantityKind.DefaultScale.Iid}:{quantityKind.DefaultScale.ShortName} in QuantityKind.DefaultScale is not in the chain of Reference Data Libraries", SeverityKind.Error);
                results.Add(result);
            }

            return(results);
        }
Beispiel #13
0
        public IEnumerable <RuleCheckResult> ChecksWhetherAReferencedDeprecatableThingIsDeprecated(Thing thing)
        {
            var unitFactor = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            var derivedUnit = (DerivedUnit)unitFactor.Container;

            if (derivedUnit.IsDeprecated)
            {
                return(results);
            }

            if (unitFactor.Unit.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id,
                                                 $"The referenced MeasurementUnit {unitFactor.Unit.Iid}:{unitFactor.Unit.ShortName} of UnitFactor.Unit is deprecated",
                                                 SeverityKind.Warning);
                results.Add(result);
            }

            return(results);
        }
        public IEnumerable <RuleCheckResult> CheckWhetherReferencedCategoryIsInChainOfRdls(Thing thing)
        {
            var referencerRule = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            var referenceDataLibrary = (ReferenceDataLibrary)referencerRule.Container;

            if (!referenceDataLibrary.IsCategoryInChainOfRdls(referencerRule.ReferencingCategory))
            {
                var result = new RuleCheckResult(thing, rule.Id, $"The ReferencerRule.RelationshipCategory {referencerRule.ReferencingCategory.Iid}:{referencerRule.ReferencingCategory.ShortName} of {referencerRule.Iid}:{referencerRule.ShortName} is not in the chain of Reference Data Libraries", SeverityKind.Error);
                results.Add(result);
            }

            foreach (var category in referencerRule.ReferencedCategory)
            {
                if (!referenceDataLibrary.IsCategoryInChainOfRdls(category))
                {
                    var result = new RuleCheckResult(thing, rule.Id, $"The ReferencerRule.ReferencedCategory {category.Iid}:{category.ShortName} of {referencerRule.Iid}:{referencerRule.ShortName} is not in the chain of Reference Data Libraries", SeverityKind.Error);
                    results.Add(result);
                }
            }

            return(results);
        }
        public IEnumerable <RuleCheckResult> CheckWheterTheLanguageCodeExistsInTheSiteDirectory(Thing thing)
        {
            var annotation = this.VerifyThingArgument(thing);

            var topContainer = thing.TopContainer;

            SiteDirectory siteDirectory;

            var engineeringModel = topContainer as EngineeringModel;

            if (engineeringModel != null)
            {
                siteDirectory = engineeringModel.EngineeringModelSetup.TopContainer as SiteDirectory;
            }
            else
            {
                siteDirectory = topContainer as SiteDirectory;
            }

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            if (siteDirectory != null)
            {
                var languageCodeExists = siteDirectory.NaturalLanguage.Any(x => x.LanguageCode == annotation.LanguageCode);
                if (!languageCodeExists)
                {
                    var result = new RuleCheckResult(thing, rule.Id, $"The Annotation.LanguageCode: {annotation.LanguageCode} for Idd: {thing.Iid} does not exist in the SiteDirectory { siteDirectory.Iid}", rule.Severity);
                    results.Add(result);
                }
            }

            return(results);
        }
Beispiel #16
0
        public IEnumerable <RuleCheckResult> ChecksWhetherAReferencedDeprecatableThingIsDeprecated(Thing thing)
        {
            var relationalExpression = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            if (relationalExpression.Scale != null && relationalExpression.Scale.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id,
                                                 $"The referenced MeasurementScale {relationalExpression.Scale.Iid}:{relationalExpression.Scale.ShortName} of RelationalExpression.Scale is deprecated",
                                                 SeverityKind.Warning);
                results.Add(result);
            }

            if (relationalExpression.ParameterType.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id,
                                                 $"The referenced ParameterType {relationalExpression.ParameterType.Iid}:{relationalExpression.ParameterType.ShortName} of RelationalExpression.ParameterType is deprecated",
                                                 SeverityKind.Warning);
                results.Add(result);
            }

            return(results);
        }
Beispiel #17
0
        public IEnumerable <RuleCheckResult> ChecksWhetherAReferencedDeprecatableThingIsDeprecated(Thing thing)
        {
            var referenceDataLibrary = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            var siteReferenceDataLibrary = referenceDataLibrary as SiteReferenceDataLibrary;

            if (siteReferenceDataLibrary != null && siteReferenceDataLibrary.IsDeprecated)
            {
                return(results);
            }

            if (referenceDataLibrary.RequiredRdl != null && referenceDataLibrary.RequiredRdl.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id,
                                                 $"The referenced SiteReferenceDataLibrary {referenceDataLibrary.RequiredRdl.Iid}:{referenceDataLibrary.RequiredRdl.ShortName} of ReferenceDataLibrary.RequiredRdl is deprecated",
                                                 SeverityKind.Warning);
                results.Add(result);
            }

            return(results);
        }
        public IEnumerable <RuleCheckResult> ChecksWhetherAReferencedDeprecatableThingIsDeprecated(Thing thing)
        {
            var siteDirectory = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            if (siteDirectory.DefaultPersonRole != null && siteDirectory.DefaultPersonRole.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id,
                                                 $"The referenced PersonRole {siteDirectory.DefaultPersonRole.Iid}:{siteDirectory.DefaultPersonRole.ShortName} of SiteDirectory.DefaultPersonRole is deprecated",
                                                 SeverityKind.Warning);
                results.Add(result);
            }

            if (siteDirectory.DefaultParticipantRole != null && siteDirectory.DefaultParticipantRole.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id,
                                                 $"The referenced ParticipantRole {siteDirectory.DefaultParticipantRole.Iid}:{siteDirectory.DefaultParticipantRole.ShortName} of SiteDirectory.DefaultParticipantRole is deprecated",
                                                 SeverityKind.Warning);
                results.Add(result);
            }

            return(results);
        }
        public Task <RuleCheckResult> CheckRuleAsync(IWordDocument document)
        {
            if (!CheckMatching(document, document.Tables.Count) || !CheckMatching(document, document.ListOfTables.Entries.Count))
            {
                return(Task.FromResult(RuleCheckResult.CreateFailure(RuleName, "List of tables not matching")));
            }

            return(Task.FromResult(RuleCheckResult.CreatePassed(RuleName)));
        }
Beispiel #20
0
        public void AddSymbol(char symbol, RuleCheckResult checkResult)
        {
            if (!this.regionSymbols.TryGetValue(checkResult, out var symbols))
            {
                symbols = new List <char>();
                this.regionSymbols.Add(checkResult, symbols);
            }

            symbols.Add(symbol);
        }
Beispiel #21
0
        public IEnumerable <RuleCheckResult> CheckWhetherSourceAndTargetAreContainedByTheSameIteration(Thing thing)
        {
            var binaryRelationship = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            if (binaryRelationship.Source == null)
            {
                throw new IncompleteModelException("The Source property is null");
            }

            if (binaryRelationship.Target == null)
            {
                throw new IncompleteModelException("The Target property is null");
            }

            var sourceIteration = binaryRelationship.Source.GetContainerOfType(typeof(Iteration));

            if (sourceIteration == null)
            {
                var result = new RuleCheckResult(thing, rule.Id, "The source is not contained by an Iteration", SeverityKind.Warning);
                results.Add(result);
            }
            else
            {
                if (sourceIteration.Iid != binaryRelationship.Container.Iid)
                {
                    var result = new RuleCheckResult(thing, rule.Id, "The source of the BinaryRelationship is not contained by the same Iteration as the BinaryRelationship", SeverityKind.Warning);
                    results.Add(result);
                }
            }

            var targetIteration = binaryRelationship.Target.GetContainerOfType(typeof(Iteration));

            if (targetIteration == null)
            {
                var result = new RuleCheckResult(thing, rule.Id, "The target is not contained by an Iteration", SeverityKind.Warning);
                results.Add(result);
            }
            else
            {
                if (targetIteration.Iid != binaryRelationship.Container.Iid)
                {
                    var result = new RuleCheckResult(thing, rule.Id, "The target of the BinaryRelationship is not contained by the same Iteration as the BinaryRelationship", SeverityKind.Warning);
                    results.Add(result);
                }
            }

            return(results);
        }
Beispiel #22
0
        public void RunRuleAgainstObject_Column_EndsWithTimeStamp()
        {
            Rule r = TestData_Rules.Columns_LogicalName_EndInTimeStamp_ExpectAppropriatePhysicalDatatype();

            DataColumn c = new DataColumn("TheColumn");

            c.ExtendedProperties["LogicalName"]      = "Insert Time Stamp";
            c.ExtendedProperties["PhysicalDatatype"] = "Timestamp";

            RuleCheckResult ruleCheckResult = r.RunRuleAgainstObject(c);

            Assert.True(ruleCheckResult.HasError);
        }
Beispiel #23
0
    public bool ValidateColumn(int[,] data, int col)
    {
        RuleCheckResult result = new RuleCheckResult();

        for (int i = 0; i < 9; i++)
        {
            int num = data[i, col];
            if (num > 0)
            {
                result.numberCounts[num - 1] = result.numberCounts[num - 1] + 1;
            }
        }

        return(result.IsValid);
    }
        public async Task <RuleCheckResult> CheckElementsAsync(string ruleName, IReadOnlyCollection <IElementWithCaption> elementsWithCaption)
        {
            return(await Task.Run(
                       () =>
            {
                var elementsWithoutCaption = elementsWithCaption.Where(f => string.IsNullOrEmpty(f.CaptionText)).ToList();

                if (elementsWithoutCaption.Any())
                {
                    return new RuleCheckResult(false, ruleName, $"{elementsWithoutCaption.Count} elements have no caption.", RuleCheckResultDetails.CreateEmpty());
                }

                return RuleCheckResult.CreatePassed(ruleName);
            }));
        }
Beispiel #25
0
    public bool ValidateRow(int[,] data, int row)
    {
        RuleCheckResult result = new RuleCheckResult();

        for (int i = 0; i < 9; i++)
        {
            int num = data[row, i];
            if (num > 0)
            {
                result.numberCounts[num - 1] = result.numberCounts[num - 1] + 1;
            }
        }

        return(result.IsValid);
    }
        public IEnumerable <RuleCheckResult> CheckWeatherTheLanguageCodeIsValid(Thing thing)
        {
            var annotation = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            if (CultureInfo.GetCultures(CultureTypes.AllCultures).All(x => x.Name != annotation.LanguageCode))
            {
                var result = new RuleCheckResult(thing, rule.Id, $"The Annotation.LanguageCode: {annotation.LanguageCode} for Idd: {thing.Iid} is not a valid LanguageCode", rule.Severity);
                results.Add(result);
            }

            return(results);
        }
Beispiel #27
0
        public IEnumerable <RuleCheckResult> ChecksWhetherAReferencedDeprecatableThingIsDeprecated(Thing thing)
        {
            var prefixedUnit = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            if (!prefixedUnit.IsDeprecated && prefixedUnit.Prefix.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id, $"The referenced UnitPrefix {prefixedUnit.Prefix.Iid}:{prefixedUnit.Prefix.ShortName} of PrefixedUnit.Prefix is deprecated", SeverityKind.Warning);
                results.Add(result);
            }

            return(results);
        }
        public Task <RuleCheckResult> CheckRuleAsync(IWordDocument document)
        {
            var tableDescsNotAbove = document
                                     .Tables
                                     .Where(f => f.Description.Position != Position.Above)
                                     .ToList();

            if (tableDescsNotAbove.Any())
            {
                var str = string.Join(", ", tableDescsNotAbove.Select(f => f.Description.PlainDescription));

                return(Task.FromResult(RuleCheckResult.CreateFailure(RuleName, str)));
            }

            return(Task.FromResult(RuleCheckResult.CreatePassed(RuleName)));
        }
        public async Task <RuleCheckResult> CheckRuleAsync(WordDocument wordDocument)
        {
            return(await Task.Run(
                       () =>
            {
                var invalidLinks = _uriCheckService.CheckInvalidUris(wordDocument.HyperLinks);

                if (!invalidLinks.Any())
                {
                    return RuleCheckResult.CreatePassed(RuleName);
                }

                var overviewMessage = $"Found {invalidLinks.Count} invalid Links.";
                var invalidLinkUris = invalidLinks.Select(link => link.Address.AbsoluteUri).ToList();
                return new RuleCheckResult(false, RuleName, overviewMessage, new RuleCheckResultDetails(invalidLinkUris));
            }));
        }
Beispiel #30
0
        public IEnumerable <RuleCheckResult> ChecksWhetherAReferencedDeprecatableThingIsDeprecated(Thing thing)
        {
            var participant = this.VerifyThingArgument(thing);

            var results       = new List <RuleCheckResult>();
            var ruleAttribute = System.Reflection.MethodBase.GetCurrentMethod().GetCustomAttribute <RuleAttribute>();
            var rule          = StaticRuleProvider.QueryRules().Single(r => r.Id == ruleAttribute.Id);

            foreach (var domainOfExpertise in participant.Domain)
            {
                if (domainOfExpertise.IsDeprecated)
                {
                    var result = new RuleCheckResult(thing, rule.Id,
                                                     $"The referenced DomainOfExpertise {domainOfExpertise.Iid}:{domainOfExpertise.ShortName} in Participant.Domain is deprecated",
                                                     SeverityKind.Warning);
                    results.Add(result);
                }
            }

            if (participant.SelectedDomain.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id,
                                                 $"The referenced DomainOfExpertise {participant.SelectedDomain.Iid}:{participant.SelectedDomain.ShortName} of Participant.SelectedDomain is deprecated",
                                                 SeverityKind.Warning);
                results.Add(result);
            }

            if (participant.Person.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id,
                                                 $"The referenced Person {participant.Person.Iid}:{participant.Person.ShortName} of Participant.Person is deprecated",
                                                 SeverityKind.Warning);
                results.Add(result);
            }

            if (participant.Role.IsDeprecated)
            {
                var result = new RuleCheckResult(thing, rule.Id,
                                                 $"The referenced ParticipantRole {participant.Role.Iid}:{participant.Role.ShortName} of Participant.Role is deprecated",
                                                 SeverityKind.Warning);
                results.Add(result);
            }

            return(results);
        }