예제 #1
0
        private IStalkNode NewLeafNode(XmlElement fragment)
        {
            LeafNode node;

            switch (fragment.Name)
            {
            case "user":
            case "page":
            case "summary":
            case "flag":
            case "log":
            case "additionaldata":
            case "targetuser":
            case "actinguser":
                return(this.NewRegexLeafNode(fragment));

            case "usergroup":
                node = new UserGroupStalkNode();
                break;

            case "incategory":
                node = new InCategoryNode();
                break;

            default:
                throw new XmlException("Unknown element " + fragment.Name);
            }

            node.SetMatchExpression(fragment.Attributes["value"].Value);

            return(node);
        }
        public void ShouldSerialiseUserGroupCorrectly()
        {
            // arrange
            var node = new UserGroupStalkNode();

            node.SetMatchExpression("abc");

            var doc = new XmlDocument();

            var snf = new StalkNodeFactory(this.phabExternalMock.Object);

            // act
            var result = snf.ToXml(doc, node);

            // assert
            Assert.AreEqual("<usergroup value=\"abc\" />", result.OuterXml);
        }
예제 #3
0
        public void LazyEvaluationInverseForceTest()
        {
            // arrange
            var rc = this.RecentChangeBuilder();

            rc.Setup(x => x.GetUserGroups()).Returns(new List <string> {
                "user", "*"
            });

            var node     = new OrNode();
            var lazyNode = new UserGroupStalkNode();

            lazyNode.SetMatchExpression("sysop");
            node.ChildNodes.Add(lazyNode);

            node.ChildNodes.Add(new FalseNode());

            // act
            node.Match(rc.Object);

            // assert
            rc.Verify(x => x.GetUserGroups(), Times.Once);
        }