Пример #1
0
        public void SaveProjectAs_NewNameWithoutConflicts()
        {
            //Arrange

            var mocks = new MockRepository();
            IProjectView projectView = mocks.StrictMock<IProjectView>();
            IProjectRepository repository = mocks.StrictMock<IProjectRepository>();

            string newProjectName = "Foo";
            Project prj = new Project("Foo");
            IProjectPresenter projectPresenter = new ProjectPresenter(projectView, repository, prj);
            using (mocks.Ordered())
            {
                Expect.Call(projectView.Title).Return(prj.Name);
                Expect.Call(repository.GetProjectByName(newProjectName)).Return(null);
                projectView.Title = newProjectName;
                projectView.HasChanges = false;
                repository.SaveProject(prj);
            }

            mocks.ReplayAll();
            //Act
            projectPresenter.SaveProjectAs();
            //Assert
            mocks.VerifyAll();
        }
Пример #2
0
 public ProjectPresenter(IProjectView projectView, Project prj)
 {
     _projectView = projectView;
     _prj = prj;
 }
Пример #3
0
 public ProjectPresenter(IProjectView projectView, IProjectRepository repository, Project prj)
     : this(projectView, prj)
 {
     _repository = repository;
 }
Пример #4
0
 public void SaveProjectAs_CanBeCanceled()
 {
     //Arrange
     var mocks = new MockRepository();
     IProjectView projectView = mocks.StrictMock<IProjectView>();
     Project prj = new Project("Example Project");
     IProjectPresenter presenter = new ProjectPresenter(projectView, prj);
     Expect.Call(projectView.Title).Return(prj.Name);
     //Expect.Call(projectView.Ask(question, asnwer))
     mocks.ReplayAll();
     //Act
     Assert.IsFalse(presenter.SaveProjectAs());
     //Assert
     mocks.VerifyAll();
 }