private static void AssertModel(JsonJobAdsModel model, params JobAd[] expectedJobAds) { AssertJsonSuccess(model); // Ensure that if there are both open and closed ads the open appear before the closed. JobAdApplicantsModel lastOpenJobAd = null; JobAdApplicantsModel firstClosedJobAd = null; try { lastOpenJobAd = model.JobAds.Last(jobAd => jobAd.Status == JobAdStatus.Open.ToString()); firstClosedJobAd = model.JobAds.First(jobAd => jobAd.Status == JobAdStatus.Closed.ToString()); } catch { //suppress errors from executing .last and .first on empty sequences } if (lastOpenJobAd != null && firstClosedJobAd != null) { Assert.IsTrue(model.JobAds.IndexOf(lastOpenJobAd) < model.JobAds.IndexOf(firstClosedJobAd)); } Assert.AreEqual(expectedJobAds.Length, model.JobAds.Count); foreach (var expectedJobAd in expectedJobAds) { var expectedJobAdId = expectedJobAd.Id; var jobAdModel = (from j in model.JobAds where j.Id == expectedJobAdId select j).Single(); AssertModel(jobAdModel, expectedJobAd); } }
protected void AssertModel(int expectedNewCount, int expectedShortlistedCount, int expectedRejectedCount, JsonJobAdsModel model) { AssertJsonSuccess(model); Assert.AreEqual(1, model.JobAds.Count); Assert.AreEqual(expectedNewCount, model.JobAds[0].ApplicantCounts.New); Assert.AreEqual(expectedShortlistedCount, model.JobAds[0].ApplicantCounts.ShortListed); Assert.AreEqual(expectedRejectedCount, model.JobAds[0].ApplicantCounts.Rejected); }