protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         _presenter.OnViewInitialized();
     }
     _presenter.OnViewLoaded();
 }
        public void OnViewLoadedCallsControllerCurrentCustomerAndViewSetCustomer()
        {
            MockCustomersController controller = new MockCustomersController();
            Customer customer = controller.InnerCurrentCustomer = new Customer();
            ApproveCustomerViewPresenter presenter = new ApproveCustomerViewPresenter(controller);
            MockApproveCustomerView view = new MockApproveCustomerView();
            presenter.View = view;

            presenter.OnViewLoaded();

            Assert.IsTrue(controller.CurrentCustomerRetrieved);
            Assert.IsTrue(view.CustomerSet);
            Assert.AreSame(customer, view.Customer);
        }
        public void OnViewLoadedCallsControllerCurrentCustomerAndViewSetCustomer()
        {
            MockCustomersController controller = new MockCustomersController();
            Customer customer = controller.InnerCurrentCustomer = new Customer();
            ApproveCustomerViewPresenter presenter = new ApproveCustomerViewPresenter(controller);
            MockApproveCustomerView      view      = new MockApproveCustomerView();

            presenter.View = view;

            presenter.OnViewLoaded();

            Assert.IsTrue(controller.CurrentCustomerRetrieved);
            Assert.IsTrue(view.CustomerSet);
            Assert.AreSame(customer, view.Customer);
        }
        public void OnViewLoadedDisablesShowingAndApprovingCustomerIfControllerCurrentCustomerIsNull()
        {
            MockCustomersController controller = new MockCustomersController();

            controller.InnerCurrentCustomer = null;
            ApproveCustomerViewPresenter presenter = new ApproveCustomerViewPresenter(controller);
            MockApproveCustomerView      view      = new MockApproveCustomerView();

            presenter.View = view;

            presenter.OnViewLoaded();

            Assert.IsTrue(controller.CurrentCustomerRetrieved);
            Assert.IsNull(view.Customer);
            Assert.IsFalse(view.AllowApproveCustomer);
            Assert.IsFalse(view.ShowCustomerDetails);
        }
        public void OnViewLoadedDisablesShowingAndApprovingCustomerIfControllerCurrentCustomerIsNull()
        {
            MockCustomersController controller = new MockCustomersController();
            controller.InnerCurrentCustomer = null;
            ApproveCustomerViewPresenter presenter = new ApproveCustomerViewPresenter(controller);
            MockApproveCustomerView view = new MockApproveCustomerView();
            presenter.View = view;

            presenter.OnViewLoaded();

            Assert.IsTrue(controller.CurrentCustomerRetrieved);
            Assert.IsNull(view.Customer);
            Assert.IsFalse(view.AllowApproveCustomer);
            Assert.IsFalse(view.ShowCustomerDetails);
        }