private static void AssertEmail(MockEmail email, IList <JobAd> jobAds, IList <IList <Member> > members) { var document = new HtmlDocument(); document.LoadHtml(email.GetHtmlView().Body); var spans = document.DocumentNode.SelectNodes("//p/span[@class='jobAdTitle']"); var divs = document.DocumentNode.SelectNodes("//p/div[@class='alert-container']"); Assert.AreEqual(jobAds.Count, members.Count); Assert.AreEqual(jobAds.Count, spans.Count); Assert.AreEqual(jobAds.Count, divs.Count); for (var index = 0; index < jobAds.Count; ++index) { Assert.AreEqual(jobAds[index].Id.ToString(), spans[index].Attributes["data-jobadid"].Value); var candidateDivs = divs[index].SelectNodes("div[@class='candidate']"); Assert.AreEqual(members[index].Count, candidateDivs.Count); for (var candidateIndex = 0; candidateIndex < candidateDivs.Count; ++candidateIndex) { var id = candidateDivs[candidateIndex].Attributes["data-id"].Value; Assert.AreEqual(members[index][candidateIndex].Id.ToString(), id); } } }
private void AssertEmail(MockEmail email, string expectedSnippet, string expectedHeaderSnippet) { foreach (var snippet in _snippets) { if (snippet == expectedSnippet) { email.AssertHtmlViewContains(snippet); } else { email.AssertHtmlViewDoesNotContain(snippet); } } var links = email.GetHtmlView().GetLinks(); AssertLink(links[0], expectedHeaderSnippet); }
protected void AssertJobAds(MockEmail email, params JobAdEntry[] jobAds) { var urls = GetJobAdUrls(email.GetHtmlView().Body); Assert.AreEqual(urls.Count, jobAds.Length); var browser = new HttpClient(); foreach (var jobAd in jobAds) { var found = false; foreach (var url in urls) { browser.Get(HttpStatusCode.OK, url.ToString()); if (browser.CurrentPageText.IndexOf(jobAd.Id.ToString().ToLower(), StringComparison.Ordinal) > -1) { found = true; break; } } Assert.IsTrue(found); } }