Ejemplo n.º 1
0
        public void PersonDetailsPresenter_OkButtonPressedInAddMode_AddsPersonToManager()
        {
            // Arrange
            FakePersonManager  manager = new FakePersonManager();
            IPersonDetailsView view    = new FakePersonDetailsView()
            {
                Forename = "Jed", Surname = "Jetson", BirthdayDay = "29", BirthdayMonth = "2"
            };
            FakeViewFactory factory = new FakeViewFactory(view);

            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager);

            presenter.AddPerson();

            //Act
            presenter.OkButtonPressed();

            //Assert
            Person addedPerson = manager.AddedPerson;

            Assert.IsNotNull(addedPerson, "The person was not added to the repository");
            Assert.AreEqual("Jed", addedPerson.Forename, "Forename not added correctly");
            Assert.AreEqual("Jetson", addedPerson.Surname, "Surname not added correctly");
            Assert.AreEqual(29, addedPerson.BirthdayDay, "BirthdayDay not added correctly");
            Assert.AreEqual(2, addedPerson.BirthdayMonth, "BirthdayMonth not added correctly");
        }
Ejemplo n.º 2
0
        public void PersonDetailsPresenter_AddPerson_SetsViewTitle()
        {
            // Arrange
            FakePersonManager       manager   = new FakePersonManager();
            FakePersonDetailsView   view      = new FakePersonDetailsView();
            FakeViewFactory         factory   = new FakeViewFactory(view);
            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager);

            //Act
            presenter.AddPerson();

            //Assert
            Assert.AreEqual("Add Person", view.Title, "Title not set in view");
        }
Ejemplo n.º 3
0
        public void PersonDetailsPresenter_OkButtonPressedInAddMode_ClosesView()
        {
            // Arrange
            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(new FakeViewFactory(), new FakePersonManager());

            presenter.AddPerson();

            //Act
            presenter.OkButtonPressed();

            //Assert
            FakePersonDetailsView view = (FakePersonDetailsView)presenter.View;

            Assert.IsTrue(view.FormClosed, "Form not closed");
        }