Exemple #1
0
        /// <summary>
        /// Create a new instance of this class
        /// </summary>
        /// <param name="view">The view to use</param>
        /// <param name="project">The project</param>
        /// <param name="isNewProject">Indicates if the project was newly created</param>
        /// <param name="projectManager">The project manager to use</param>
        /// <param name="runner">The rule runner to use</param>
        /// <param name="violationList">The violation list to sue</param>
        public MainController(IMainView view,
                              ICalidusProjectModel project,
                              bool isNewProject,
                              ICalidusProjectManager projectManager,
                              IRuleRunner runner,
                              IRuleViolationList violationList)
        {
            _view = view;

            _view.Open += new EventHandler <EventArgs>(_view_Open);
            _view.Save += new EventHandler <EventArgs>(_view_Save);
            _view.Quit += new EventHandler <QuitEventArgs>(_view_Quit);

            _view.ProjectConfiguration += new EventHandler <EventArgs>(_view_ProjectConfiguration);
            _view.RuleConfiguration    += new EventHandler <EventArgs>(_view_RuleConfiguration);

            _projectManager = projectManager;

            _runner            = runner;
            _runner.Started   += new EventHandler <EventArgs>(_runner_Started);
            _runner.Completed += new EventHandler <RuleRunnerEventArgs>(_runner_Completed);

            _violationList = violationList;

            _project             = project;
            _project.Changed    += new EventHandler <EventArgs>(_project_Changed);
            _project.ProjectSet += new EventHandler <EventArgs>(_project_ProjectSet);

            //set project details
            _view.SelectedProject = _project.GetProjectFile();
            HasChanges            = isNewProject;
        }
Exemple #2
0
        /// <summary>
        /// Create a new instance of this class
        /// </summary>
        /// <param name="view">The view to use</param>
        /// <param name="model">The model to use</param>
        public SourceLocationController(ISourceLocationView view, ICalidusProjectModel model)
        {
            _view = view;

            _model = model;

            _view.DisplayProjectFileLocation(_model.GetProjectFile());
        }
        public void SourceLocationControllerShouldDisplayProjectFileLocation()
        {
            ISourceLocationView  view  = Mocker.DynamicMock <ISourceLocationView>();
            ICalidusProjectModel model = Mocker.DynamicMock <ICalidusProjectModel>();

            Expect.Call(model.GetProjectFile()).Return("test.calidus").Repeat.Once();
            Expect.Call(() => view.DisplayProjectFileLocation("test.calidus")).Repeat.Once();

            Mocker.ReplayAll();

            SourceLocationController controller = new SourceLocationController(view, model);

            Mocker.VerifyAll();
        }
Exemple #4
0
        public void MainControllerShouldSetViewSelectedProjectToProjectFileName()
        {
            IMainView              view           = Mocker.DynamicMock <IMainView>();
            ICalidusProjectModel   projectModel   = Mocker.DynamicMultiMock <ICalidusProjectModel>(typeof(ICalidusProject));
            ICalidusProjectManager projectManager = Mocker.DynamicMock <ICalidusProjectManager>();
            IRuleRunner            ruleRunner     = Mocker.DynamicMock <IRuleRunner>();
            IRuleViolationList     violationList  = Mocker.DynamicMock <IRuleViolationList>();

            //Expect.Call(view.SelectedProject = @"c:\test.calidus").Repeat.Once();
            Expect.Call(projectModel.GetProjectFile()).Return(@"c:\test.calidus").Repeat.Once();

            Mocker.ReplayAll();

            MainController controller = new MainController(view, projectModel, false, projectManager, ruleRunner, violationList);

            Mocker.VerifyAll();
        }
Exemple #5
0
        public void MainControllerShouldConfirmSaveChangedWhenViewOpenCalledWithHasChanges()
        {
            Expect.Call(_projectModel.GetProjectFile()).Return(@"c:\test.calidus").Repeat.Times(1);
            Expect.Call(_view.ConfirmSaveChanges()).Return(Confirm.Cancel);

            Mocker.ReplayAll();

            _controller              = new MainController(_view, _projectModel, true, _projectManager, _ruleRunner, _violationList);
            _view.Raise(x => x.Open += null, this, EventArgs.Empty);

            Mocker.VerifyAll();
        }
Exemple #6
0
 private void _project_ProjectSet(object sender, EventArgs e)
 {
     _view.SelectedProject = _project.GetProjectFile();
 }