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(); }
public ProjectPresenter(IProjectView projectView, Project prj) { _projectView = projectView; _prj = prj; }
public ProjectPresenter(IProjectView projectView, IProjectRepository repository, Project prj) : this(projectView, prj) { _repository = repository; }
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(); }