public BlockParserContext(IProblemPipe problemPipe, Fragment returnFragmentType, List<ReturnCondition> returnConditions, IBlacklistManager blacklistManager, BlockParser.InspectCallback inspect)
 {
     _problemPipe = problemPipe;
       _returnFragmentType = returnFragmentType;
       _returnConditions = returnConditions;
       _blacklistManager = blacklistManager;
       _inspect = inspect;
 }
Exemplo n.º 2
0
        public void Parse_ValidReturnWithIf_ReturnsCorrectReturnFragmentType()
        {
            _blockParser = new BlockParser (_blacklist, _problemPipeStub,Fragment.CreateNamed( "DummyFragment"), new List<ReturnCondition>());
              TypeNode stringTypeNode = IntrospectionUtility.TypeNodeFactory<string>();
              Method sampleMethod = TestHelper.GetSample<BlockParserSample> ("ValidReturnWithLiteralAssignmentInsideIf", stringTypeNode);
              Block sample = sampleMethod.Body.Statements[3] as Block;
              BasicBlock returnedBlock = _blockParser.Parse (sample);
              var preConditionFragmentType = returnedBlock.PreConditions[0].Fragment;

              Assert.That (preConditionFragmentType, Is.EqualTo (Fragment.CreateNamed("DummyFragment")));
        }
Exemplo n.º 3
0
 public void SetUp()
 {
     _blacklist = new IDbCommandBlacklistManagerStub();
       _problemPipeStub = new ProblemPipeStub();
       _returnPreCondition = new ReturnCondition ("returnPreCondition", Fragment.CreateNamed("ReturnPreConditionFragmentType"));
       List<ReturnCondition> returnPreConditions = new List<ReturnCondition> { _returnPreCondition };
       _blockParser = new BlockParser (_blacklist, _problemPipeStub, c_returnFragmentType, returnPreConditions);
 }
Exemplo n.º 4
0
        public void Parse_ReturnFragmentRequiredUnsafeReturn_ReturnsCorrectReturnFragmentType2()
        {
            var returnFragmentType = Fragment.CreateNamed ("ReturnFragmentType2");

              _blockParser = new BlockParser (_blacklist, _problemPipeStub, returnFragmentType, new List<ReturnCondition>());
              Method sampleMethod = TestHelper.GetSample<BlockParserSample> ("UnsafeReturnWhenFragmentRequired");
              Block sample = sampleMethod.Body.Statements[1] as Block;
              BasicBlock returnedBlock = _blockParser.Parse (sample);
              var preConditionFragment = returnedBlock.PreConditions[0].Fragment;

              Assert.That (preConditionFragment, Is.EqualTo (returnFragmentType));
        }