示例#1
0
        static int Main(string[] args)
        {
            string configurationFilePath;
            string inputPath = "";

            if (args.Length != 2)
            {
                Console.WriteLine("Input Path not provided");
                return(-1);
            }
            configurationFilePath = args[0];
            inputPath             = args[1];
            if (Helper.CheckDirectoryExists(inputPath))
            {
                if (Helper.CheckFileExists(configurationFilePath))
                {
                    Console.WriteLine("Welcome to Static Analysis Tool");

                    IConfiguration toolsConfiguration     = new ToolsConfiguration(configurationFilePath);
                    var            toolsConfigurationList = toolsConfiguration.LoadConfiguration();

                    StaticAnalysisApplication staticAnalysis = new StaticAnalysisApplication(toolsConfigurationList);

                    int errorcode = staticAnalysis.Run(inputPath);
                    if (errorcode == -2)
                    {
                        return(-2);
                    }
                }
            }
            return(0);
        }
示例#2
0
        public void given_toolObjectList_when_toolInvoked_then_noExceptionExpected()
        {
            var            configurationFilepath = @"C:\Users\320050767\Source\Repos\G7CaseStudy13\StaticAnalyzer\ConfigurationLib\Configuration.xml";
            var            inputPath             = @"C:\Users\320050767\Source\Repos\G7CaseStudy13\StaticAnalyzer";
            IConfiguration toolsConfiguration    = new ToolsConfiguration(configurationFilepath);
            var            toolList       = toolsConfiguration.LoadConfiguration();
            var            staticAnalyzer = new StaticAnalysisApplication(toolList);

            staticAnalyzer.Run(inputPath);
        }
示例#3
0
        public void given_configurationFile_when_Loaded_then_validCountExpected()
        {
            var            configurationFilepath = @"C:\Users\320050767\Source\Repos\G7CaseStudy13\StaticAnalyzer\ConfigurationLib\Configuration.xml";
            IConfiguration toolsConfiguration    = new ToolsConfiguration(configurationFilepath);
            var            toolList      = toolsConfiguration.LoadConfiguration();
            var            expectedValue = toolList.Count;
            var            actualValue   = 1;

            Assert.AreEqual(expectedValue, actualValue);
        }
示例#4
0
        private void toolsConfigCombo_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (EventsHandlingPaused)
            {
                return;
            }

            ToolsConfiguration config = (ToolsConfiguration)toolsConfigCombo.SelectedIndex;

            ConfigureTools(config);
        }
示例#5
0
        public void given_configurationToolList_when_objectCreated_then_validCountExpecetd()
        {
            var            configurationFilepath = @"C:\Users\320050767\Source\Repos\G7CaseStudy13\StaticAnalyzer\ConfigurationLib\Configuration.xml";
            IConfiguration toolsConfiguration    = new ToolsConfiguration(configurationFilepath);
            var            toolList           = toolsConfiguration.LoadConfiguration();
            var            staticAnalyzer     = new StaticAnalysisApplication(toolList);
            var            staticAnalyzerList = staticAnalyzer.ToolObjectList;
            var            expectedValue      = staticAnalyzerList.Count();
            var            actualValue        = 1;

            Assert.AreEqual(expectedValue, actualValue);
        }
示例#6
0
        private void ConfigureTools(ToolsConfiguration config)
        {
            // initially remove all tools from the view tools collection
            view.Controller.Tools.Clear();

            // determine which tools must be created and in what order
            bool createPointer          = false;
            bool createDelegators       = false;
            bool pointerBeforeDelegator = false;

            switch (config)
            {
            case ToolsConfiguration.OnlyEventDelagators:
                createPointer    = false;
                createDelegators = true;
                break;

            case ToolsConfiguration.OnlyPointer:
                createPointer    = true;
                createDelegators = false;
                break;

            case ToolsConfiguration.PointerBeforeEventDelagators:
                createPointer          = true;
                createDelegators       = true;
                pointerBeforeDelegator = true;
                break;

            case ToolsConfiguration.EventDelagatorsBeforePointer:
                createPointer          = true;
                createDelegators       = true;
                pointerBeforeDelegator = false;
                break;

            default:
                Debug.Assert(false, "New tools config?");
                break;
            }

            // create the needed tools
            NTool[] pointerTools = null, delegatorTools = null;
            if (createPointer)
            {
                pointerTools = new NTool[] { new NCreateGuidelineTool(),
                                             new NHandleTool(),
                                             new NMoveTool(),
                                             new NSelectorTool(),
                                             new NContextMenuTool(),
                                             new NKeyboardTool(),
                                             new NInplaceEditTool() };
            }

            if (createDelegators)
            {
                delegatorTools = new NTool[] { new NMouseEventDelegatorTool(),
                                               new NKeyboardEventDelegatorTool(),
                                               new NDragDropEventDelegatorTool() };
            }

            // add them in the proper order
            if (pointerBeforeDelegator)
            {
                if (pointerTools != null)
                {
                    foreach (NTool tool in pointerTools)
                    {
                        view.Controller.Tools.Add(tool);
                    }
                }

                if (delegatorTools != null)
                {
                    foreach (NTool tool in delegatorTools)
                    {
                        view.Controller.Tools.Add(tool);
                    }
                }
            }
            else
            {
                if (delegatorTools != null)
                {
                    foreach (NTool tool in delegatorTools)
                    {
                        view.Controller.Tools.Add(tool);
                    }
                }

                if (pointerTools != null)
                {
                    foreach (NTool tool in pointerTools)
                    {
                        view.Controller.Tools.Add(tool);
                    }
                }
            }

            // enable all tools
            view.Controller.Tools.EnableAllTools();
        }