Exemple #1
0
        public void Build_ReturnsAllStatementHandlersNeededByBlockParser()
        {
            MockRepository     mocks              = new MockRepository();
            IBlacklistManager  blacklistManager   = mocks.Stub <IBlacklistManager>();
            IProblemPipe       problemPipe        = mocks.Stub <IProblemPipe>();
            BlockParserContext blockParserContext = new BlockParserContext(
                problemPipe,
                Fragment.CreateNamed("returnFragmentType"),
                new List <ReturnCondition>(),
                blacklistManager,
                delegate { });
            StatementHandlerDictionaryBuilder builder = new StatementHandlerDictionaryBuilder(blockParserContext);

            Dictionary <Type, IStatementHandler> handlers = builder.Build();
            bool assignmentStatementSupported             = handlers.ContainsKey(typeof(AssignmentStatement));
            bool branchSupported = handlers.ContainsKey(typeof(Branch));
            bool expressionStatementSupported = handlers.ContainsKey(typeof(ExpressionStatement));
            bool returnNodeSupported          = handlers.ContainsKey(typeof(ReturnNode));
            bool switchInstructionSupported   = handlers.ContainsKey(typeof(SwitchInstruction));

            bool necessaryHandlersSupported = assignmentStatementSupported &&
                                              branchSupported &&
                                              expressionStatementSupported &&
                                              returnNodeSupported &&
                                              switchInstructionSupported;

            bool correctHandlerCount = handlers.Keys.Count == 5;

            Assert.That(necessaryHandlersSupported && correctHandlerCount, Is.True);
        }
        public BlockParser(
            IBlacklistManager blacklistManager, IProblemPipe problemPipe, Fragment returnFragmentType, List <ReturnCondition> returnConditions)
        {
            _blacklistManager   = ArgumentUtility.CheckNotNull("blacklistManager", blacklistManager);
            _problemPipe        = ArgumentUtility.CheckNotNull("typeParser", problemPipe);
            _returnFragmentType = returnFragmentType;
            _returnConditions   = returnConditions;
            BlockParserContext blockParserContext = new BlockParserContext(
                _problemPipe, _returnFragmentType, _returnConditions, _blacklistManager, Inspect
                );
            StatementHandlerDictionaryBuilder handlerBuilder = new StatementHandlerDictionaryBuilder(blockParserContext);

            _statementHandlers  = handlerBuilder.Build();
            _methodCallAnalyzer = new MethodCallAnalyzer(_problemPipe);
        }