コード例 #1
0
        public void IsMatch_IdentifierAndIdentifierPattern_True()
        {
            const string text = "  a1vd ";

            var lexicalRule = MockRepository.GenerateMock<ILexicalRule>();
            lexicalRule.Expect(r => r.Pattern).Return(IdentifierExpression);
            var compiledLexicalRule = new CompiledLexicalRule(lexicalRule);

            Assert.That(compiledLexicalRule.IsMatch(text), Is.True);
            lexicalRule.VerifyAllExpectations();
        }
コード例 #2
0
        public void IsWrongRule_WrongPattern_True()
        {
            const string pattern = @"^(?<e>[\s\S]*)$";
            const string text = "  a1vd bu ";

            var lexicalRule = MockRepository.GenerateMock<ILexicalRule>();
            lexicalRule.Expect(r => r.Pattern).Return(pattern);
            var compiledLexicalRule = new CompiledLexicalRule(lexicalRule);

            Assert.That(compiledLexicalRule.IsMatch(text), Is.True);
            Assert.That(compiledLexicalRule.IsWrongRule(text), Is.True);
            lexicalRule.VerifyAllExpectations();
        }