Exemplo n.º 1
0
        public MethodGraphBuilder(Method method, IBlacklistManager blacklistManager, IProblemPipe problemPipe, Fragment returnFragment)
            : this(method, blacklistManager, problemPipe)
        {
            ArgumentUtility.CheckNotNull("returnFragment", returnFragment);

            _returnFragment = returnFragment;
        }
        public void ArrayConstructIsParsed()
        {
            MockRepository            mocks                    = new MockRepository();
            IBlacklistManager         blacklistManager         = mocks.Stub <IBlacklistManager>();
            Dictionary <string, bool> locallyInitializedArrays = new Dictionary <string, bool>();
            BlockParserContext        blockParserContext       = new BlockParserContext(
                new ProblemPipeStub(),
                Fragment.CreateNamed("returnFragmentType"),
                new List <ReturnCondition>(),
                blacklistManager,
                delegate { });
            ArrayConstructStatementHandler handler = new ArrayConstructStatementHandler(blockParserContext);

            Method    sampleMethod = IntrospectionUtility.MethodFactory <ArrayConstructStatementHandlerSample> ("LocallyInitializedArray");
            Block     sampleBlock  = (Block)sampleMethod.Body.Statements[0];
            Statement sample       = sampleBlock.Statements[1];

            ISymbolTable  symbolTable = mocks.Stub <ISymbolTable>();
            HandleContext context     = new HandleContext(
                sample,
                symbolTable,
                new List <IPreCondition>(),
                new List <string>(),
                new List <BlockAssignment>(),
                new List <int>(),
                locallyInitializedArrays,
                new Dictionary <string, bool>());

            handler.Handle(context);

            bool locallyInitializedArrayAdded = locallyInitializedArrays.ContainsKey("local$2") && locallyInitializedArrays["local$2"] == false;

            Assert.That(locallyInitializedArrayAdded, Is.True);
        }
        public void SetUp()
        {
            _problemMetadata = new ProblemMetadata(0, new SourceContext(), Fragment.CreateEmpty(), Fragment.CreateEmpty());
            MockRepository mocks = new MockRepository();

            _blacklistManager = mocks.Stub <IBlacklistManager>();
        }
Exemplo n.º 4
0
 public void InitializeBlacklistManager(TypeNode type)
 {
     if (_blacklistManager == null)
     {
         _blacklistManager = ConfigurationFactory.CreateFrom(type, new ConfigurationFileLocator());
     }
 }
Exemplo n.º 5
0
 public EmbeddedInitialSymbolTableBuilder(Method method, IBlacklistManager blacklistManager, ISymbolTable environment)
     : base(method, blacklistManager)
 {
     ArgumentUtility.CheckNotNull("environment", environment);
     _result           = environment;
     _symbolTableBuilt = false;
 }
Exemplo n.º 6
0
        public void Handle_WrongStatementType_ThrowsException()
        {
            MockRepository     mocks              = new MockRepository();
            IBlacklistManager  blacklistManager   = mocks.Stub <IBlacklistManager>();
            BlockParserContext blockParserContext = new BlockParserContext(
                new ProblemPipeStub(),
                Fragment.CreateNamed("returnFragmentType"),
                new List <ReturnCondition>(),
                blacklistManager,
                delegate { });

            StatementHandlerBase <AssignmentStatement> handler = new AssignmentStatementHandlerController(blockParserContext);
            Method    sampleMethod = IntrospectionUtility.MethodFactory <StatementHandlerBaseSample> ("ContainsReturnStatement");
            Block     sampleBlock  = (Block)sampleMethod.Body.Statements[1];
            Statement sample       = sampleBlock.Statements[0];

            ISymbolTable  symbolTable = mocks.Stub <ISymbolTable>();
            HandleContext context     = new HandleContext(
                sample,
                symbolTable,
                new List <IPreCondition>(),
                new List <string>(),
                new List <BlockAssignment>(),
                new List <int>(),
                new Dictionary <string, bool>(),
                new Dictionary <string, bool>());

            handler.Handle(context);
        }
 public void SetUp()
 {
     _blacklistManager = new IDbCommandBlacklistManagerStub();
     _environment      = new SymbolTable(_blacklistManager);
     _floatType        = IntrospectionUtility.TypeNodeFactory <float>();
     _objectType       = IntrospectionUtility.TypeNodeFactory <object>();
 }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public void SetUp()
        {
            MockRepository    mocks            = new MockRepository();
            IBlacklistManager blacklistManager = mocks.Stub <IBlacklistManager>();

            _customInferenceController = new CustomInferenceController();
            _symbolTable = new SymbolTable(blacklistManager);
        }
Exemplo n.º 10
0
 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.º 11
0
 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.º 12
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.º 13
0
 public void SetUp()
 {
     _blacklistManager    = new IDbCommandBlacklistManagerStub();
     _methodPreConditions = new SymbolTable(_blacklistManager);
     _methodPreConditions.MakeSafe("x", Fragment.CreateNamed("SqlFragment"));
     _methodPreConditions.MakeSafe("l", Fragment.CreateLiteral());
     _methodPreConditions.MakeUnsafe("y");
     _problemPipeStub     = new ProblemPipeStub();
     _methodGraphAnalyzer = new MethodGraphAnalyzer(_problemPipeStub);
     _mocks                       = new MockRepository();
     _methodGraph                 = _mocks.Stub <IMethodGraph>();
     _methodGraphBuilder          = _mocks.Stub <IMethodGraphBuilder>();
     _parameterSymbolTableBuilder = _mocks.Stub <IInitialSymbolTableBuilder>();
 }
Exemplo n.º 14
0
 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);
 }
Exemplo n.º 15
0
        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);
        }
        public void SetUp()
        {
            MockRepository     mocks              = new MockRepository();
            IBlacklistManager  blacklistManager   = mocks.Stub <IBlacklistManager>();
            BlockParserContext blockParserContext = new BlockParserContext(
                new ProblemPipeStub(),
                Fragment.CreateNamed("returnFragmentType"),
                new List <ReturnCondition>(),
                blacklistManager,
                delegate { });

            _handler     = new StringBuilderConstructStatementHandler(blockParserContext);
            _symbolTable = new SymbolTable(blacklistManager);
            _stringBuilderFragmentTypesDefined = new Dictionary <string, bool>();
        }
        public void IsViolated_ViolatingContext_ChangesProblemMetadatasGivenType()
        {
            var                  expectedFragment   = Fragment.CreateNamed("expectedFragment");
            var                  unexpectedFragment = Fragment.CreateNamed("unexpectedFragment");
            ProblemMetadata      problemMetaData    = new ProblemMetadata(0, new SourceContext(), expectedFragment, Fragment.CreateNamed("dummy"));
            IBlacklistManager    blackListManager   = _mocks.Stub <IBlacklistManager>();
            EqualityPreCondition preCondition       = new EqualityPreCondition("testSymbol", expectedFragment, problemMetaData);
            SymbolTable          context            = new SymbolTable(blackListManager);

            context.MakeSafe("testSymbol", unexpectedFragment);

            preCondition.IsViolated(context);

            Assert.That(problemMetaData.GivenFragment, Is.EqualTo(unexpectedFragment));
        }
Exemplo n.º 18
0
 public LoanController(IMapper mapper, ILoanManager loanManager, IEquipmentManager equipmentManager, IUserRepository userRepository,
                       ILoanEquipmentManager loanEquipmentManager, IEmailScheduleManager emailScheduleManager,
                       IApplicationEmailSender emailSender, IBlacklistManager blacklistManager,
                       UserManager <IdentityUser> userManager, ILoanExtensionManager loanExtensionManager,
                       IConfigurationManager configurationManager, IConfiguration configuration)
 {
     __Mapper               = mapper ?? throw new ArgumentNullException(nameof(mapper));
     __LoanManager          = loanManager ?? throw new ArgumentNullException(nameof(loanManager));
     __EquipmentManager     = equipmentManager ?? throw new ArgumentNullException(nameof(equipmentManager));
     __UserRepository       = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
     __LoanEquipmentManager = loanEquipmentManager ?? throw new ArgumentNullException(nameof(loanEquipmentManager));
     __EmailScheduleManager = emailScheduleManager ?? throw new ArgumentNullException(nameof(emailScheduleManager));
     __BlacklistManager     = blacklistManager ?? throw new ArgumentNullException(nameof(blacklistManager));
     __UserManager          = userManager ?? throw new ArgumentNullException(nameof(userManager));
     __LoanExtensionManager = loanExtensionManager ?? throw new ArgumentNullException(nameof(loanExtensionManager));
     __ConfigurationManager = configurationManager ?? throw new ArgumentNullException(nameof(configurationManager));
     __Configuration        = configuration ?? throw new ArgumentNullException(nameof(configuration));
 }
Exemplo n.º 19
0
        public MethodGraphBuilder(Method method, IBlacklistManager blacklistManager, IProblemPipe problemPipe)
        {
            ArgumentUtility.CheckNotNull("method", method);
            _blacklistManager = ArgumentUtility.CheckNotNull("blacklistManager", blacklistManager);
            _problemPipe      = ArgumentUtility.CheckNotNull("problemPipe", problemPipe);
            bool isInterfaceMethod = method.Body.Statements == null;

            if (!isInterfaceMethod)
            {
                _methodBody = method.Body;
                _referenceAndOutConditions = ReferenceAndOutConditions(method);
                _result = null;
            }
            else
            {
                _result = new MethodGraph(-1, new Dictionary <int, BasicBlock>());
            }
            _returnFragment = FragmentUtility.ReturnFragmentType(method);
        }
 public void SetUp()
 {
     _blacklistManager = new IDbCommandBlacklistManagerStub();
       _floatType = IntrospectionUtility.TypeNodeFactory<float>();
       _objectType = IntrospectionUtility.TypeNodeFactory<object>();
 }
Exemplo n.º 21
0
 public SymbolTable(IBlacklistManager blacklistManager)
 {
     _blacklistManager = ArgumentUtility.CheckNotNull("blacklistManager", blacklistManager);
       _safenessMap = new Dictionary<string, Fragment>();
       _customInferenceController = new CustomInferenceController();
 }
 public void SetUp()
 {
     _blacklistManager = new IDbCommandBlacklistManagerStub();
       _methodPreConditions = new SymbolTable (_blacklistManager);
       _methodPreConditions.MakeSafe ("x", Fragment.CreateNamed("SqlFragment"));
       _methodPreConditions.MakeSafe ("l", Fragment.CreateLiteral());
       _methodPreConditions.MakeUnsafe ("y");
       _problemPipeStub = new ProblemPipeStub();
       _methodGraphAnalyzer = new MethodGraphAnalyzer (_problemPipeStub);
       _mocks = new MockRepository();
       _methodGraph = _mocks.Stub<IMethodGraph>();
       _methodGraphBuilder = _mocks.Stub<IMethodGraphBuilder>();
       _parameterSymbolTableBuilder = _mocks.Stub<IInitialSymbolTableBuilder>();
 }
 public ParameterSymbolTableBuilder(Method method, IBlacklistManager blacklistManager)
 {
     _method = ArgumentUtility.CheckNotNull ("method", method);
       _blacklistManager = ArgumentUtility.CheckNotNull ("blacklistManager", blacklistManager);
       _result = null;
 }
Exemplo n.º 24
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.º 25
0
 public SymbolTable(IBlacklistManager blacklistManager)
 {
     _blacklistManager          = ArgumentUtility.CheckNotNull("blacklistManager", blacklistManager);
     _safenessMap               = new Dictionary <string, Fragment>();
     _customInferenceController = new CustomInferenceController();
 }
Exemplo n.º 26
0
 public void InitializeBlacklistManager(TypeNode type)
 {
     if (_blacklistManager == null)
     _blacklistManager = ConfigurationFactory.CreateFrom (type, new ConfigurationFileLocator());
 }
Exemplo n.º 27
0
 public TypeParser(IBlacklistManager blacklistManager)
     : base("TypeParser")
 {
     _problemFilter = new ProblemDuplicateFilter (this);
       _blacklistManager = blacklistManager;
 }
 public BlacklistController(IMapper mapper, IBlacklistManager blacklistManager)
 {
     __Mapper           = mapper ?? throw new ArgumentNullException(nameof(mapper));
     __BlacklistManager = blacklistManager ?? throw new ArgumentException(nameof(blacklistManager));
 }
Exemplo n.º 29
0
 public TypeParser(IBlacklistManager blacklistManager)
     : base("TypeParser")
 {
     _problemFilter    = new ProblemDuplicateFilter(this);
     _blacklistManager = blacklistManager;
 }
 public ParameterSymbolTableBuilder(Method method, IBlacklistManager blacklistManager)
 {
     _method           = ArgumentUtility.CheckNotNull("method", method);
     _blacklistManager = ArgumentUtility.CheckNotNull("blacklistManager", blacklistManager);
     _result           = null;
 }
 public void SetUp()
 {
     _problemMetadata = new ProblemMetadata (0, new SourceContext(), Fragment.CreateEmpty(), Fragment.CreateEmpty());
       MockRepository mocks = new MockRepository();
       _blacklistManager = mocks.Stub<IBlacklistManager>();
 }