public void NextTokenShouldNotReturnWhiteSpaceToken() { TokenBase identifier = TokenCreator.Create <IdentifierToken>("test"); TokenBase space = TokenCreator.Create <SpaceToken>(); StatementBase classStatement = StatementCreator.CreateClassStatement(); StatementBase memberStatement = StatementCreator.CreateMemberStatement("test"); IList <TokenBase> totalList = new List <TokenBase>(); foreach (TokenBase aToken in classStatement.Tokens) { totalList.Add(aToken); } foreach (TokenBase aToken in memberStatement.Tokens) { totalList.Add(aToken); } totalList.Add(space); totalList.Add(identifier); IList <TokenBase> identifierList = new List <TokenBase>(); identifierList.Add(space); identifierList.Add(identifier); _manager.Encountered(new[] { classStatement }, classStatement.Tokens.Count(), totalList); Assert.AreEqual(identifier, _manager.GetContext(memberStatement.Tokens).NextTokenFromCurrentStatement); }
public void FileBlockFactoryReturnedBlockStatementsShouldBeAllStatements() { IList <StatementBase> input = new List <StatementBase>(); input.Add(StatementCreator.CreateMemberStatement("_this")); input.Add(StatementCreator.CreateMemberStatement("_that")); CollectionAssert.AreEquivalent(input, _factory.Create(input).ElementAt(0).Statements); }
public void StatementParentsShouldBeEqual() { StatementBase alphaStatement = StatementCreator.CreateMemberStatement("test"); StatementBase alphaDelimiter = StatementCreator.CreateOpenBlockStatement(); TokenCreator.Reset(); StatementBase bravoStatement = StatementCreator.CreateMemberStatement("test"); StatementBase bravoDelimiter = StatementCreator.CreateOpenBlockStatement(); StatementParent alpha = new StatementParent(new[] { alphaStatement }, alphaDelimiter); StatementParent bravo = new StatementParent(new[] { bravoStatement }, bravoDelimiter); Assert.AreEqual(alpha, bravo); }
public void ParserShouldCallSBlockFactoryWhenParsingStatements() { IList <StatementBase> input = new List <StatementBase>(); input.Add(StatementCreator.CreateMemberStatement("_someString")); IBlockFactory factory = Mocker.StrictMock <IBlockFactory>(); Expect.Call(factory.Create(input)).Return(new [] { new BlockBaseImpl(input) }).Repeat.Once(); StubBlockFactoryProvider provider = new StubBlockFactoryProvider(factory); CalidusBlockParser parser = new CalidusBlockParser(provider); Mocker.ReplayAll(); parser.Parse(input); Mocker.VerifyAll(); }
public override void SetUp() { base.SetUp(); _statement = StatementCreator.CreateMemberStatement("member"); }
public void RuleShouldReturnInvalidForStatementsThatDoNotMatchThePattern() { MemberNameMatchesPatternRule rule = new MemberNameMatchesPatternRule(new Regex("^_[a-z]+"), false); Assert.IsFalse(rule.IsValidFor(StatementCreator.CreateMemberStatement("ATest"))); }
public void RuleShouldValidateStatements() { MemberNameMatchesPatternRule rule = new MemberNameMatchesPatternRule(new Regex(""), false); Assert.IsTrue(rule.Validates(StatementCreator.CreateMemberStatement("member"))); }
public void ExplicitAccessModifierRuleShouldValidateMembers() { Assert.IsTrue(_rule.Validates(StatementCreator.CreateMemberStatement("test"))); }