示例#1
0
        public void RuleShouldReturnValidForStatementsThatDoNotMatchThePatternButArePublicStatic()
        {
            MemberNameMatchesPatternRule rule = new MemberNameMatchesPatternRule(new Regex("^_[a-z]+"), true);

            IList <TokenBase> input = new List <TokenBase>();

            input.Add(TokenCreator.Create <PublicModifierToken>());
            input.Add(TokenCreator.Create <SpaceToken>());
            input.Add(TokenCreator.Create <StaticToken>());
            input.Add(TokenCreator.Create <SpaceToken>());
            input.Add(TokenCreator.Create <IdentifierToken>("String"));
            input.Add(TokenCreator.Create <SpaceToken>());
            input.Add(TokenCreator.Create <IdentifierToken>("Test"));
            input.Add(TokenCreator.Create <SemiColonToken>());

            MemberStatement member = new MemberStatement(input, null);

            Assert.IsTrue(rule.IsValidFor(member));
        }
示例#2
0
        public void RuleShouldReturnInvalidForStatementsThatDoNotMatchThePattern()
        {
            MemberNameMatchesPatternRule rule = new MemberNameMatchesPatternRule(new Regex("^_[a-z]+"), false);

            Assert.IsFalse(rule.IsValidFor(StatementCreator.CreateMemberStatement("ATest")));
        }
示例#3
0
        public void RuleShouldValidateStatements()
        {
            MemberNameMatchesPatternRule rule = new MemberNameMatchesPatternRule(new Regex(""), false);

            Assert.IsTrue(rule.Validates(StatementCreator.CreateMemberStatement("member")));
        }