private AccountController GetAccountController() { var fakeOrganizationRepository = new FakeOrganizationRepository(); userProfileRepository = new FakeUserProfileRepository(); campaignDonorRepository = new FakeCampaignDonorRepository(); mocks = new MockRepository(); var fakeEmailService = mocks.DynamicMock<IAccountMailer>(); MailerBase.IsTestModeEnabled = true; AccountController c = new AccountController(userProfileRepository, fakeEmailService, campaignDonorRepository) { FormsService = new MockFormsAuthenticationService(), MembershipService = new MockMembershipService(), OrganizationRepository = fakeOrganizationRepository }; TestHelpers.MockHttpContext(c, mocks, postFiles: false); return c; }
private CampaignController GetCampaignController(bool isAjaxRequest = false) { var organizationRepository = new FakeOrganizationRepository(); var organization = organizationRepository.GetDefaultOrganization(readOnly: false); var causeTemplate = EntityHelpers.GetValidCauseTemplate(); causeTemplate.CauseTemplateID = 1; organization.CauseTemplates = new List<CauseTemplate> { causeTemplate }; campaignRepository = new FakeCampaignRepository(); causeTemplateRepository = new FakeCauseTemplateRepository(); userProfileRepository = new FakeUserProfileRepository(); var mocks = new MockRepository(); var mailer = mocks.DynamicMock<ICampaignMailer>(); MailerBase.IsTestModeEnabled = true; var c = new CampaignController(campaignRepository, causeTemplateRepository, userProfileRepository, mailer) { OrganizationRepository = organizationRepository }; var context = MockRepository.GenerateStub<HttpContextBase>(); var request = MockRepository.GenerateStub<HttpRequestBase>(); context.Stub(x => x.Request).Return(request); context.User = new GenericPrincipal(new GenericIdentity("goodEmail"), null); c.ControllerContext = new ControllerContext(context, new RouteData(), c); return c; }