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; }
public void SetUp() { controller = GetCampaignController(); Mapper.CreateMap<Campaign, CampaignDetailsModel>(); Mapper.CreateMap<Campaign, CampaignCreateModel>(); Mapper.CreateMap<Campaign, CampaignAdminModel>(); }