Esempio n. 1
0
        bool IProjectPresenter.SaveProjectAs()
        {
            string projectName = m_View.Title;

            m_View.Ask(null, null);
            return(false);
        }
        public void SaveProjectAs_CanBeCanceled()
        {
            MockRepository    mocks     = new MockRepository();
            IProjectView      view      = mocks.StrictMock <IProjectView>();
            Project           prj       = new Project("Example Project");
            IProjectPresenter presenter = new ProjectPresenter(prj, view);

            Expect.Call(view.Title).Return(prj.Name);
            Expect.Call(view.Ask(null, null)).Return("a");

            mocks.ReplayAll();
            Assert.IsFalse(presenter.SaveProjectAs());
            mocks.VerifyAll();
        }
Esempio n. 3
0
        bool IProjectPresenter.SaveProjectAs()
        {
            string projectName = m_View.Title;

            if (m_Repository.GetProjectByName(m_View.Ask("Mock ?", "Yes")) == null)
            {
                m_View.Title      = "RhinoMocks";
                m_Prj.Name        = "RhinoMocks";
                m_View.HasChanges = false;

                m_Repository.SaveProject(m_Prj);
                return(true);
            }

            return(false);
        }
        public void SaveProjectAs_NewNameWithoutConflicts()
        {
            MockRepository     mocks      = new MockRepository();
            IProjectView       view       = mocks.StrictMock <IProjectView>();
            IProjectRepository repository = mocks.StrictMock <IProjectRepository>();
            IProject           prj        = mocks.StrictMock <IProject>();

            //Component to test
            IProjectPresenter presenter = new ProjectPresenter(prj, repository, view);

            string question       = "Mock ?";
            string answer         = "Yes";
            string newProjectName = "RhinoMocks";

            //Not expected but its necessary for the implementation
            //We give the property behavior to prj.Name
            Expect.Call(prj.Name).PropertyBehavior();

            using (mocks.Ordered())
            {
                Expect.Call(view.Title).
                Return(prj.Name);
                Expect.Call(view.Ask(question, answer)).
                Return(newProjectName);
                Expect.Call(repository.GetProjectByName(newProjectName)).
                Return(null);

                view.Title      = newProjectName;
                view.HasChanges = false;

                repository.SaveProject(prj);
            }

            mocks.ReplayAll();

            Assert.IsTrue(presenter.SaveProjectAs());
            Assert.AreEqual(newProjectName, prj.Name);

            mocks.VerifyAll();
        }