public void t_SiteVisit_SelectAllForSite() { // Backdoor setup List <SiteVisit_ado> list = DbTestHelper.LoadExtraneousSiteVisits(); // Exercise the test List <SiteVisit> resultList = SiteVisitMapper.SelectAllForSite(list[0].LocationId); // Validate results Assert.AreEqual(resultList.Count(), 1, "Wrong number of objects in the result list"); foreach (SiteVisit_ado ado in list.FindAll(x => x.LocationId.Equals(list[0].LocationId))) { // just check to make sure the object is there; leave specific value check for the Select_ByGuid test Assert.IsTrue(resultList.Exists(x => x.Id.Equals(ado.EventId)), "SiteVisitAdo " + ado.EventId.ToString() + " is not in the results"); } }
protected void RetrieveIncomplete_Click(object sender, EventArgs e) { if (this.SiteVisitedInput.SelectedIndex > -1 && !string.IsNullOrEmpty(this.VisitDateInput.Text)) { List <SiteVisit> visitList = SiteVisitMapper.SelectAllForSite(Guid.Parse(this.SiteVisitedInput.SelectedValue)); SiteVisit theVisit = visitList.Find(x => !x.IsDataEntryComplete && x.StartTimeStamp.Value.ToShortDateString() .Equals( DateTime.Parse(this.VisitDateInput.Text).ToShortDateString())); if (theVisit != null) { resetSession(); this.UserState.SiteVisit = theVisit; this.UserState.SiteVisit.SupplementalObservations.AddRange( SupplementalObservationMapper.SelectAllForEvent(theVisit.Id)); this.UserState.SiteVisit.PointSurveys.AddRange(PointSurveyMapper.SelectAllForSiteVisit(theVisit.Id)); this.UserState.SiteVisit.PointSurveys.ForEach(x => { x.Observations.AddRange(ObservationMapper.SelectAllForEvent <PointCountBeyond50>(x.Id)); x.Observations.AddRange(ObservationMapper.SelectAllForEvent <PointCountWithin50>(x.Id)); }); List <SiteCondition> conditions = ConditionsMapper.Select_BySiteVisitId(theVisit.Id); if (conditions != null && conditions.Count.Equals(2)) { this.UserState.SiteVisit.StartConditions = conditions.Single(x => x.Id.Equals(this.UserState.SiteVisit.StartConditions.Id)); this.UserState.SiteVisit.EndConditions = conditions.Single(x => x.Id.Equals(this.UserState.SiteVisit.EndConditions.Id)); } loadCurrentSiteVisit(); } else { Master.SetErrorMessage( "<p>No <i>incomplete</i> site visit entry has been started for this site and date.</p>"); } } else { Master.SetErrorMessage( "<p>Both site and date must be filled in to retrieve an incomplete site visit.</p>"); } }