Example #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //get the project file
            StartUpWindow win = new StartUpWindow();

            win.ShowDialog();

            //if a file selected
            if (win.DialogResult == DialogResult.OK)
            {
                //build main objects
                CalidusProjectManager           projectManager = new CalidusProjectManager();
                CalidusProjectModel             project        = new CalidusProjectModel(projectManager.ReadFrom(win.SelectedProjectFile));
                CalidusRuleConfigurationFactory configFactory  = new CalidusRuleConfigurationFactory(project, projectManager);

                RuleRunner        runner        = new RuleRunner();
                RuleViolationList violationList = new RuleViolationList();

                //prepare main view
                MainWindow mainView = new MainWindow();

                //assign controllers
                MainController c = new MainController(mainView, project, win.IsNewProject, projectManager, runner, violationList);

                ViolationListController     violationListController     = new ViolationListController(mainView.ViolationListView, project, violationList);
                CheckableRuleTreeController checkableRuleListController = new CheckableRuleTreeController(mainView.CheckableRuleTreeView, new CalidusRuleProvider(), configFactory);
                FileTreeController          fileListController          = new FileTreeController(mainView.FileListView, project);
                SourceLocationController    sourceLocationController    = new SourceLocationController(mainView.SourceLocationView, project);
                RuleRunnerController        ruleRunnerController        = new RuleRunnerController(mainView.RuleRunnerView, runner, project, configFactory);
                StatusController            statusController            = new StatusController(mainView.StatusView, violationList);

                //run application
                Application.Run(mainView);
            }
        }
Example #2
0
        public void MainControllerShouldAddViolationsToViolationListOnRunnerCompleted()
        {
            IList <RuleViolation> vList = new List <RuleViolation>();

            vList.Add(new RuleViolation(null, null, new List <TokenBase>()));

            RuleViolationList expected = new RuleViolationList();

            foreach (RuleViolation v in vList)
            {
                expected.Add(v);
            }

            RuleViolationList actual = new RuleViolationList();

            Expect.Call(_projectModel.GetProjectFile()).Return(@"c:\test.calidus").Repeat.Times(1);

            Mocker.ReplayAll();

            _controller = new MainController(_view, _projectModel, true, _projectManager, _ruleRunner, actual);
            _ruleRunner.Raise(x => x.Completed += null, this, new RuleRunnerEventArgs(vList));

            CollectionAssert.AreEquivalent(expected, actual);
        }