/// <summary> /// Loads extra PointSurvey objects to improve testing /// </summary> /// <returns> /// List of <see cref="PointSurvey_ado"/> objects /// </returns> public static List <PointSurvey_ado> LoadExtraneousPointSurveys() { List <PointSurvey_ado> surveyList = new List <PointSurvey_ado>(); PointSurvey_ado extra1 = PointSurvey_ado.CreatePointSurvey_ado(TestHelper.TestGuid1, TestHelper.TestGuid1, DateTime.Now, DateTime.Now.AddMinutes(5)); extra1.NoiseCode = 0; extra1.SiteVisitId = TestHelper.TestGuid1; LoadAdoObjects((IbaUnitTestEntities iba) => { iba.AddToPointSurvey_ado1(extra1); }); surveyList.Add(extra1); PointSurvey_ado extra2 = PointSurvey_ado.CreatePointSurvey_ado(TestHelper.TestGuid2, TestHelper.TestGuid2, DateTime.Now.AddMinutes(10), DateTime.Now.AddMinutes(15)); extra2.NoiseCode = 0; extra2.SiteVisitId = TestHelper.TestGuid1; LoadAdoObjects((IbaUnitTestEntities iba) => { iba.AddToPointSurvey_ado1(extra2); }); surveyList.Add(extra2); return(surveyList); }
public void t_PointSurvey_Delete() { PointSurvey_ado setupObject = null; // backdoor data setup DbTestHelper.LoadAdoObjects(delegate(IbaUnitTestEntities iba) { setupObject = PointSurvey_ado.CreatePointSurvey_ado(TestHelper.TestGuid3, TestHelper.TestGuid1, DateTime.Now, DateTime.Now.AddMinutes(5)); setupObject.NoiseCode = 0; setupObject.SiteVisitId = TestHelper.TestGuid1; iba.AddToPointSurvey_ado1(setupObject); }); List <PointSurvey_ado> PointSurveyAdolist = DbTestHelper.LoadExtraneousPointSurveys(); PointSurveyMapper.Delete(new FiftyMeterPointSurvey() { Id = setupObject.EventId }); // Validate results using (IbaUnitTestEntities iba = new IbaUnitTestEntities()) { var PointSurveyQuery = from PointSurveys in iba.PointSurvey_ado1 select PointSurveys; Assert.IsNotNull(PointSurveyQuery, "Query result is null"); Assert.AreEqual(PointSurveyAdolist.Count(), PointSurveyQuery.Count(), "Wrong number of results in query"); validateExtraPointSurveyAdos(PointSurveyAdolist, PointSurveyQuery); } }
/// <summary> /// Loads a single PointSurvey to the database /// </summary> /// <param name="endDateTime"></param> /// <param name="startdateTime"></param> /// <param name="locationId"></param> /// <param name="siteVisitId"></param> /// <param name="pointSurveyId">Guid</param> public static PointSurvey_ado LoadSinglePointSurvey(Guid pointSurveyId, Guid siteVisitId, Guid locationId, DateTime startdateTime, DateTime endDateTime) { PointSurvey_ado ado = null; LoadAdoObjects((IbaUnitTestEntities iba) => { ado = PointSurvey_ado.CreatePointSurvey_ado(pointSurveyId, locationId, startdateTime, endDateTime); ado.SiteVisitId = siteVisitId; iba.AddToPointSurvey_ado1(ado); }); return(ado); }
private void setupOakwood() { Location_ado site = Location_ado.CreateLocation_ado(TestHelper.TestGuid1, OAKWOOD, LookupConstants.LocationTypeSite); Location_ado point = Location_ado.CreateLocation_ado(TestHelper.TestGuid2, "Point", LookupConstants.LocationTypePoint); point.ParentLocationId = site.LocationId; SiteVisit_ado visit = DbTestHelper.LoadSingleSiteVisit(TestHelper.TestGuid1, site.LocationId, DateTime.Now.AddHours(-7)); PointSurvey_ado survey = PointSurvey_ado.CreatePointSurvey_ado(TestHelper.TestGuid2, point.LocationId, DateTime.Now.AddHours(-7), DateTime.Now.AddHours(-6)); survey.SiteVisitId = visit.EventId; DbTestHelper.LoadAdoObjects((IbaUnitTestEntities iba) => { iba.AddToPointSurvey_ado1(survey); iba.AddToLocation_ado(site); iba.AddToLocation_ado(point); iba.SaveChanges(); }); List <Observation_ado> obsList = new List <Observation_ado>(); addABunchOfObservations(obsList, 35, List[0].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 26, List[1].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 21, List[2].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 16, List[3].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 11, List[4].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 6, List[5].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 5, List[6].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 3, List[7].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 3, List[8].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 3, List[9].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 3, List[10].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 3, List[11].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 2, List[12].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 2, List[13].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 2, List[14].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 1, List[15].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 1, List[16].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 1, List[17].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 1, List[18].SpeciesId, survey.EventId); addABunchOfObservations(obsList, 25, List[19].SpeciesId, survey.EventId); loadObservations(obsList); }
public void t_SelectAllForEvent_SiteVisit() { Guid siteVisitid = DbTestHelper.TestGuid3; DbTestHelper.LoadSingleSiteVisit(siteVisitid); Guid eventId = DbTestHelper.TestGuid1; Guid eventId2 = DbTestHelper.TestGuid2; Guid speciesId1 = new Guid(DbTestHelper.SPECIES_1_ID); Guid speciesId2 = new Guid(DbTestHelper.SPECIES_2_ID); string speciesCode1 = DbTestHelper.SPECIES_1_CODE; string speciesCode2 = DbTestHelper.SPECIES_2_CODE; string comments1 = string.Empty; string comments2 = "comments 2"; DbTestHelper.LoadAdoObjects((IbaUnitTestEntities iba) => { PointSurvey_ado survey1 = PointSurvey_ado.CreatePointSurvey_ado(eventId, true, DbTestHelper.TestGuid2, DateTime.Now, DateTime.Now.AddHours(2)); survey1.SiteVisitId = siteVisitid; iba.AddToPointSurvey_ado1(survey1); PointSurvey_ado survey2 = PointSurvey_ado.CreatePointSurvey_ado(eventId2, true, DbTestHelper.TestGuid2, DateTime.Now, DateTime.Now.AddHours(2)); survey2.SiteVisitId = siteVisitid; iba.AddToPointSurvey_ado1(survey2); }); multiBackdoorSetup(eventId, speciesId1, speciesId2, comments1, comments2); multiBackdoorSetup(eventId2, speciesId1, speciesId2, comments1, comments2); // Run the system List<FiftyMeterDataEntry> entryList = FiftyMeterDataEntryMapper.SelectAllForEvent(siteVisitid); // Validate results Assert.IsNotNull(entryList, "entrylist is null"); Assert.AreEqual(4, entryList.Count(), "entrylist does not contain 4 objects"); // TODO: need to make sure the grouping handles different PointSurveyId values, separating them appropriately. ValidateFiftyMeterDataEntryObject(eventId, comments1, entryList, "1", 0, 1, speciesCode1); ValidateFiftyMeterDataEntryObject(eventId, comments2, entryList, "2", 2, 1, speciesCode2); ValidateFiftyMeterDataEntryObject(eventId2, comments1, entryList, "1", 0, 1, speciesCode1); ValidateFiftyMeterDataEntryObject(eventId2, comments2, entryList, "2", 2, 1, speciesCode2); }
public void t_PointSurvey_Select_ByGuid() { PointSurvey_ado setupObject = null; // backdoor data setup DbTestHelper.LoadAdoObjects(delegate(IbaUnitTestEntities iba) { setupObject = PointSurvey_ado.CreatePointSurvey_ado(TestHelper.TestGuid3, TestHelper.TestGuid1, DateTime.Now, DateTime.Now.AddMinutes(5)); setupObject.NoiseCode = 0; setupObject.SiteVisitId = TestHelper.TestGuid1; iba.AddToPointSurvey_ado1(setupObject); }); List <PointSurvey_ado> extraList = DbTestHelper.LoadExtraneousPointSurveys(); // Exercise the test FiftyMeterPointSurvey resultObject = PointSurveyMapper.Select(setupObject.EventId); validateObjectEquality(resultObject, setupObject); }
public void t_PointSurvey_Save_Update() { PointSurvey_ado setupObject = null; // backdoor data setup DbTestHelper.LoadAdoObjects(delegate(IbaUnitTestEntities iba) { setupObject = PointSurvey_ado.CreatePointSurvey_ado(TestHelper.TestGuid3, TestHelper.TestGuid1, DateTime.Now, DateTime.Now.AddMinutes(5)); setupObject.NoiseCode = 0; setupObject.SiteVisitId = TestHelper.TestGuid1; iba.AddToPointSurvey_ado1(setupObject); }); List <PointSurvey_ado> extraList = DbTestHelper.LoadExtraneousPointSurveys(); // Setup object to be saved. Change everything except the Id. FiftyMeterPointSurvey toSave = new FiftyMeterPointSurvey() { Id = setupObject.EventId, EndTimeStamp = setupObject.EndTime.AddHours(1), LocationId = TestHelper.TestGuid4, NoiseCode = 0, StartTimeStamp = setupObject.StartTime.AddHours(0.5) }; // Execute the test PointSurveyMapper.Update(toSave); // Validate results using (IbaUnitTestEntities iba = new IbaUnitTestEntities()) { var PointSurveyQuery = from PointSurveys in iba.PointSurvey_ado1 select PointSurveys; Assert.IsNotNull(PointSurveyQuery, "Query result is null"); Assert.AreEqual(extraList.Count() + 1, PointSurveyQuery.Count(), "Wrong number of results in query"); PointSurvey_ado adoPointSurvey = PointSurveyQuery.First(x => x.EventId == setupObject.EventId); validateObjectEquality(toSave, adoPointSurvey); validateExtraPointSurveyAdos(extraList, PointSurveyQuery); } }