Esempio n. 1
0
        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            var presenter = new CompanyDetailPresenter(this);

            presenter.Delete();
            Response.Redirect("~/Pages/Companies.aspx");
        }
        public void Save_NoId()
        {
            bool addCalled                = false;
            bool updateCalled             = false;
            ICompanyRepository repository = new StubICompanyRepository
            {
                AddCompany = x =>
                {
                    addCalled = true;
                },
                UpdateCompany = x =>
                {
                    updateCalled = true;
                }
            };

            this.view.CompanyIdField = 0;

            var presenter = new CompanyDetailPresenter(this.view, repository);

            presenter.Save();

            Assert.IsTrue(addCalled);
            Assert.IsFalse(updateCalled);
            Assert.IsTrue((this.view as MockCompanyDetailView).CanUserDelete);
        }
        public void Load_Id()
        {
            bool methodCalled             = false;
            ICompanyRepository repository = new StubICompanyRepository
            {
                GetByIdInt32 = x =>
                {
                    methodCalled = true;
                    return(new Company {
                        Id = x, Name = "Test Company"
                    });
                }
            };

            this.view.CompanyIdField = 3;

            var presenter = new CompanyDetailPresenter(this.view, repository);

            presenter.Load();
            Assert.IsTrue(methodCalled);

            Assert.IsTrue((this.view as MockCompanyDetailView).CanUserDelete);
            Assert.AreEqual(3, this.view.CompanyIdField);
            Assert.AreEqual("Test Company", this.view.NameField);
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                if (this.IsQueryStringValid("id0"))
                {
                    this.CompanyIdField = Convert.ToInt32(this.Request.QueryString.Get("id0"));
                }

                var presenter = new CompanyDetailPresenter(this);
                presenter.Load();
            }
        }
        public void Delete_EnsureCalled()
        {
            bool methodCalled             = false;
            ICompanyRepository repository = new StubICompanyRepository
            {
                DeleteInt32 = x =>
                {
                    methodCalled = true;
                }
            };

            var presenter = new CompanyDetailPresenter(this.view, repository);

            presenter.Delete();
            Assert.IsTrue(methodCalled);
        }
Esempio n. 6
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            var presenter = new CompanyDetailPresenter(this);

            presenter.Save();
        }