public void PersonDetailsPresenter_OkButtonPressedInEditMode_ClosesView() { // Arrange IPersonDetailsPresenter presenter = new PersonDetailsPresenter(new FakeViewFactory(), new FakePersonManager()); presenter.EditPerson(PersonObjectMother.GetPerson(TestPeople.Ted)); // sets to edit mode //Act presenter.OkButtonPressed(); //Assert FakePersonDetailsView view = (FakePersonDetailsView)presenter.View; Assert.IsTrue(view.FormClosed, "Form not closed"); }
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"); }
public void PersonDetailsPresenter_OkButtonPressedInUndefinedMode_ThrowsException() { // Arrange IPersonDetailsPresenter presenter = new PersonDetailsPresenter(new FakeViewFactory(), new FakePersonManager()); //Act ApplicationException expectedException = null; try{ presenter.OkButtonPressed(); } catch (ApplicationException ex){ expectedException = ex; } //Assert Assert.IsNotNull(expectedException, "Exception not thrown as expected"); }
public void PersonDetailsPresenter_OkButtonPressedInEditMode_UpdatesPersonInManager() { // Arrange FakePersonManager manager = new FakePersonManager(); IPersonDetailsPresenter presenter = new PersonDetailsPresenter(new FakeViewFactory(), manager); Person p = PersonObjectMother.GetPerson(TestPeople.Sue); presenter.EditPerson(p); //Act presenter.OkButtonPressed(); //Assert Person updatedPerson = manager.UpdatedPerson; Assert.IsNotNull(updatedPerson, "The person was not updated in the manager"); Assertions.AssertPeopleAreEqual(p, updatedPerson); }
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"); }