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"); }
public void PersonDetailsPresenter_ShowView_ShowsView() { // Arrange FakePersonManager manager = new FakePersonManager(); FakePersonDetailsView view = new FakePersonDetailsView(); FakeViewFactory factory = new FakeViewFactory(view); IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager); //Act presenter.ShowView(false); //Assert Assert.IsTrue(view.FormShown, "View not shown"); }
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"); }
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_EditPerson_PassesCorrectDetailsToView() { // Arrange FakePersonManager manager = new FakePersonManager(); FakePersonDetailsView view = new FakePersonDetailsView(); FakeViewFactory factory = new FakeViewFactory(view); IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager); //Act presenter.EditPerson(PersonObjectMother.GetPerson(TestPeople.Ted)); //Assert Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).Forename, view.Forename, "Forename not set in view"); Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).Surname, view.Surname, "Surname not set in view"); Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).BirthdayDay.ToString(), view.BirthdayDay, "BirthdayDay not set in view"); Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).BirthdayMonth.ToString(), view.BirthdayMonth, "BirthdayMonth not set in view"); }
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"); }
public void PersonDetailsPresenter_ShowView_ShowsView() { // Arrange FakePersonManager manager = new FakePersonManager(); FakePersonDetailsView view = new FakePersonDetailsView(); FakeViewFactory factory = new FakeViewFactory(view); IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager); //Act presenter.ShowView(false); //Assert Assert.IsTrue(view.FormShown, "View not shown"); }
public void PersonDetailsPresenter_EditPerson_PassesCorrectDetailsToView() { // Arrange FakePersonManager manager = new FakePersonManager(); FakePersonDetailsView view = new FakePersonDetailsView(); FakeViewFactory factory = new FakeViewFactory(view); IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager); //Act presenter.EditPerson(PersonObjectMother.GetPerson(TestPeople.Ted)); //Assert Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).Forename, view.Forename, "Forename not set in view"); Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).Surname, view.Surname, "Surname not set in view"); Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).BirthdayDay.ToString(), view.BirthdayDay, "BirthdayDay not set in view"); Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).BirthdayMonth.ToString(), view.BirthdayMonth, "BirthdayMonth not set in view"); }
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"); }