예제 #1
0
        public void GetScanResults_NoRuleResults_EmptyResult()
        {
            A11yElement element = GenerateA11yElement();

            using (ShimsContext.Create())
            {
                ShimResultsFileSarifMapper.FetchOrAddRuleRuleResult = (_) =>
                {
                    return(GenerateRule());
                };

                ShimResultsFileSarifMapper.GetFingerPrintContributionsA11yElementRuleResult = (_, __) =>
                {
                    Dictionary <string, string> fingerPrintContributions = new Dictionary <string, string>();
                    fingerPrintContributions.Add(FrameworkKey, FrameworkValue);
                    fingerPrintContributions.Add("Level", "open");
                    fingerPrintContributions.Add("LocalizedControlType", "page");
                    fingerPrintContributions.Add("Name", "Welcome page");
                    fingerPrintContributions.Add("RuleId", "BoundingRectangleSizeReasonable");
                    return(fingerPrintContributions);
                };

                ShimResultsFileSarifMapper.GetResultMessagesListOfString = (_) =>
                {
                    return(new Message(TestMessage, null, TestMessage, null, null, null));
                };
                List <Tuple <Rule, Result> > elementResults = ResultsFileSarifMapper.GetScanResults(element, String.Empty);
                Assert.IsNotNull(elementResults);
                Assert.AreEqual(0, elementResults.Count);
            }
        }
예제 #2
0
        public void GetScanResults_A11yElementNull_EmptyResult()
        {
            List <Tuple <Rule, Result> > elementResults = ResultsFileSarifMapper.GetScanResults(null, String.Empty);

            Assert.IsNotNull(elementResults);
            Assert.AreEqual(0, elementResults.Count);
        }
예제 #3
0
        public void GetScanResults_A11yElementScanResultsItemEmpty_EmptyResult()
        {
            A11yElement element = GenerateA11yElement();
            List <Tuple <Rule, Result> > elementResults = ResultsFileSarifMapper.GetScanResults(element, String.Empty);

            Assert.IsNotNull(elementResults);
            Assert.AreEqual(0, elementResults.Count);
        }
예제 #4
0
        public void GetScanResults_ReceivesNormalParameters_ProducesScanResultList()
        {
            A11yElement       element     = GenerateA11yElement();
            RuleResult        result      = new RuleResult();
            List <RuleResult> ruleResults = new List <RuleResult>();

            ruleResults.Add(result);
            element.ScanResults.Items[0].Items = ruleResults;
            using (ShimsContext.Create())
            {
                ShimResultsFileSarifMapper.FetchOrAddRuleRuleResult = (_) =>
                {
                    return(GenerateRule());
                };

                ShimScanStatusExtensions.ToResultLevelScanStatus = (_) =>
                {
                    return(ResultLevel.Open);
                };

                ShimResultsFileSarifMapper.GetFingerPrintContributionsA11yElementRuleResult = (_, __) =>
                {
                    Dictionary <string, string> fingerPrintContributions = new Dictionary <string, string>();
                    fingerPrintContributions.Add(FrameworkKey, FrameworkValue);
                    fingerPrintContributions.Add("Level", "open");
                    fingerPrintContributions.Add("LocalizedControlType", "page");
                    fingerPrintContributions.Add("Name", "Welcome page");
                    fingerPrintContributions.Add("RuleId", "BoundingRectangleSizeReasonable");
                    return(fingerPrintContributions);
                };

                ShimResultsFileSarifMapper.GetResultMessagesListOfString = (_) =>
                {
                    return(new Message(TestMessage, null, null, null, null, null));
                };
                List <Tuple <Rule, Result> > elementResults = ResultsFileSarifMapper.GetScanResults(element, String.Empty);

                Assert.IsNotNull(elementResults);
                Assert.AreEqual(1, elementResults.Count);
                Tuple <Rule, Result> elementScanOutput = elementResults[0];
                Assert.IsNotNull(elementScanOutput);

                Rule   rule = elementScanOutput.Item1;
                Result res  = elementScanOutput.Item2;
                Assert.IsNotNull(rule);
                Assert.IsNotNull(res);

                Assert.AreEqual(TestRuleName, rule.Name.Text);
                Assert.AreEqual(ResultLevel.Open, res.Level);

                Assert.IsNotNull(res.PartialFingerprints);
                Assert.IsTrue(res.PartialFingerprints.ContainsKey(FrameworkKey));
                string partialfingerprintFramework = String.Empty;
                Assert.IsTrue(res.PartialFingerprints.TryGetValue(FrameworkKey, out partialfingerprintFramework));
                Assert.AreEqual(FrameworkValue, partialfingerprintFramework);
                Assert.AreEqual(res.Locations[0].Annotations[0].Snippet.Text, TestGlimpse);
            }
        }
예제 #5
0
        public void GetScanResults_NullRuleResultListUnderScanItems_EmptyResult()
        {
            // The structure is a little confusing. ScanResults has a list of Items (RuleResults)
            A11yElement element = GenerateA11yElement();

            element.ScanResults.Items[0].Items = null;
            List <Tuple <Rule, Result> > elementResults = ResultsFileSarifMapper.GetScanResults(element, String.Empty);

            Assert.IsNotNull(elementResults);
            Assert.AreEqual(0, elementResults.Count);
        }