public JsonResult GetCampaigns() { int accountID = UserExtensions.ToAccountID(this.Identity); GetCampaignsResponse response = leadScoreService.GetCampaigns(new GetCampaignsRequest() { accountId = accountID }); return(Json(new { success = true, response = response.Campaigns }, JsonRequestBehavior.AllowGet)); }
public void GetCampaigns_ValidCampaigns_Success() { var campaigns = new List <Campaign>(); campaigns.Add(new Campaign() { Id = 1, Name = "Campaign1", AccountID = 1 }); campaigns.Add(new Campaign() { Id = 2, Name = "Campaign2", AccountID = 1 }); mockLeadScoreRuleRepository.Setup(lsr => lsr.GetCampaigns(It.IsAny <int>())).Returns(campaigns); GetCampaignsResponse response = leadScoreRuleService.GetCampaigns(new GetCampaignsRequest() { AccountId = 1 }); mockRepository.VerifyAll(); Assert.AreEqual(campaigns.Count, response.Campaigns.Count()); Assert.AreEqual(null, response.Exception); }