Beispiel #1
0
        public void MainControllerShouldCallSetProjectOnProjectModelOnViewOpen()
        {
            ICalidusProject theProject = Mocker.DynamicMock <ICalidusProject>();

            Expect.Call(_projectModel.GetProjectFile()).Return(@"c:\test.calidus").Repeat.Times(1);
            Expect.Call(delegate { _projectModel.SetProject(theProject); }).Repeat.Once();
            Expect.Call(_view.OpenProjectFile()).Return(new FileBrowseResult(true, @"c:\test.calidus")).Repeat.Once();
            Expect.Call(_projectManager.ReadFrom("test")).IgnoreArguments().Return(theProject).Repeat.Once();

            Mocker.ReplayAll();

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

            Mocker.VerifyAll();
        }
Beispiel #2
0
        private void _view_Open(object sender, EventArgs e)
        {
            if (HasChanges)
            {
                Confirm confirm = _view.ConfirmSaveChanges();
                if (confirm == Confirm.Yes)
                {
                    SaveProject();
                }

                if (confirm == Confirm.Cancel)
                {
                    return;
                }
            }

            FileBrowseResult openResult = _view.OpenProjectFile();

            if (openResult.IsOk && !String.IsNullOrEmpty(openResult.SelectedFile))
            {
                _project.SetProject(_projectManager.ReadFrom(openResult.SelectedFile));
                HasChanges = false;
            }
        }