コード例 #1
0
        public void TraverseTreeDepthFirst_NoScanResultsInElement_EmptyResult()
        {
            using (ShimsContext.Create())
            {
                ShimResultsFileSarifMapper.GetScanResultsA11yElementString = (_, __) =>
                {
                    return(new List <Tuple <Rule, Result> >());
                };

                ShimDataManager.GetDefaultInstance = () =>
                {
                    ShimDataManager shimDM = new ShimDataManager
                    {
                        GetElementContextGuid = (_) =>
                        {
                            return(new ElementContext(new A11yElement()));
                        }
                    };
                    return(shimDM);
                };

                List <Tuple <Rule, Result> > elementResults = ResultsFileSarifMapper.TraverseTreeDepthFirst(guid);
                Assert.IsNotNull(elementResults);
                Assert.AreEqual(0, elementResults.Count);
            }
        }
        /// <summary>
        /// Set up all of the shims needed for the unit tests--we make no attempt to
        /// identify a subset of shims to configure
        /// </summary>
        private static void InitializeShims()
        {
            ShimDataManager shimDataManager = new ShimDataManager();

            ShimDataManager.GetDefaultInstance = () => shimDataManager;

            ShimSelectAction shimSelectAction = new ShimSelectAction();

            ShimSelectAction.GetDefaultInstance = () => shimSelectAction;
        }
コード例 #3
0
        public void TraverseTreeDepthFirst_ReceivesRequiredParameters_NonEmptyResult()
        {
            using (ShimsContext.Create())
            {
                ShimResultsFileSarifMapper.GetScanResultsA11yElementString = (_, __) =>
                {
                    List <Tuple <Rule, Result> > scanResults = new List <Tuple <Rule, Result> >();
                    Rule   rule   = GenerateRule();
                    Result result = GenerateResult();
                    scanResults.Add(new Tuple <Rule, Result>(rule, result));
                    return(scanResults);
                };

                ShimDataManager.GetDefaultInstance = () =>
                {
                    ShimDataManager shimDM = new ShimDataManager
                    {
                        GetElementContextGuid = (_) =>
                        {
                            A11yElement element      = GenerateA11yElement();
                            A11yElement childElement = new A11yElement();
                            element.Children.Add(childElement);
                            return(new ElementContext(element));
                        }
                    };
                    return(shimDM);
                };

                List <Tuple <Rule, Result> > elementResults = ResultsFileSarifMapper.TraverseTreeDepthFirst(guid);

                Assert.IsNotNull(elementResults);
                Assert.AreEqual(2, elementResults.Count);
                Tuple <Rule, Result> elementResult = elementResults[0];
                Assert.IsNotNull(elementResult);
                Assert.IsNotNull(elementResult.Item1);
                Assert.IsNotNull(elementResult.Item2);
                Assert.AreEqual(TestRuleName, elementResult.Item1.Name.Text);
                Assert.AreEqual(ResultLevel.Open, elementResult.Item2.Level);
            }
        }