public void ProductEditPresenter_GetId_ReturnsIdFromQueryString()
        {
            //arange
            int expectedId = 1234;
            var view = MockRepository.GenerateMock<IEditProductView<EditProductModel>>();
            view.Expect(v => v.Model).Return(new EditProductModel());

            var httpContext = MockRepository.GenerateMock<HttpContextBase>();
            var httpRequest = MockRepository.GenerateMock<HttpRequestBase>();
            httpContext.Expect(h => h.Request).Return(httpRequest);
            httpRequest.Expect(r => r.QueryString["id"]).Return(expectedId.ToString());

            var p = new ProductEditPresenter(view) { HttpContext = httpContext };

            //act
            int actualId = p.GetId();

            //assert
            Assert.AreEqual<Int32>(expectedId, actualId);
        }
        public void ProductEditPresenter_PopulateViewModel_SupplyingAnIdExpectingEditMode()
        {
            //arange
            var view = MockRepository.GenerateMock<IEditProductView<EditProductModel>>();
            view.Expect(v => v.Model).Return(new EditProductModel());

            var httpContext = MockRepository.GenerateMock<HttpContextBase>();
            var httpRequest = MockRepository.GenerateMock<HttpRequestBase>();
            httpContext.Expect(h => h.Request).Return(httpRequest);
            httpRequest.Expect(r => r.QueryString["id"]).Return("1");

            var repo = MockRepository.GenerateMock<IRepository>();
            repo.Expect(r => r.GetProduct(1)).Return(new Product());

            var p = new ProductEditPresenter(view) { HttpContext = httpContext, Repository = repo };

            var expectedMode = EditMode.Edit;

            //act
            p.PopulateViewModel();

            //assert
            Assert.AreEqual<EditMode>(expectedMode, p.View.Model.PageEditMode);
        }