public void t_PointCountBeyond50_Select() { Observation_ado setupObject = null; // backdoor data setup Guid pointSurveyId = TestHelper.TestGuid3; DbTestHelper.LoadSinglePointSurvey(pointSurveyId, TestHelper.TestGuid2, TestHelper.TestGuid1, DateTime.Now, DateTime.Now.AddHours(1)); DbTestHelper.LoadAdoObjects(delegate(IbaUnitTestEntities iba) { setupObject = new Observation_ado() { Comments = "asdfasdf asdf adsfa dsfads fasdf adsfasd fadsf awefr34fr34r34 ", SpeciesId = new Guid(TestHelper.SPECIES_1_ID), EventId = pointSurveyId, ObservationTypeId = _PointCountBeyond50TypeId }; iba.AddToObservation_ado(setupObject); }); DbTestHelper.LoadExtraneousObservations(TestHelper.TestGuid3); // Exercise the test PointCountBeyond50 PointCountBeyond50 = ObservationMapper.Select <PointCountBeyond50>(setupObject.ObservationId); using (IbaUnitTestEntities iba = new IbaUnitTestEntities()) { validateObjectEquality(PointCountBeyond50, setupObject, iba); } }
public void t_PointCountBeyond50_Select_ByEventId() { Guid pointSurveyId = TestHelper.TestGuid2; DbTestHelper.LoadSinglePointSurvey(pointSurveyId, TestHelper.TestGuid2, TestHelper.TestGuid1, DateTime.Now, DateTime.Now.AddHours(1)); Observation_ado setupObject = null; // backdoor data setup DbTestHelper.LoadAdoObjects(delegate(IbaUnitTestEntities iba) { setupObject = new Observation_ado() { Comments = "asdfasdf asdf adsfa dsfads fasdf adsfasd fadsf awefr34fr34r34 ", SpeciesId = new Guid(TestHelper.SPECIES_1_ID), EventId = pointSurveyId, ObservationTypeId = _PointCountBeyond50TypeId }; iba.AddToObservation_ado(setupObject); }); DbTestHelper.LoadExtraneousObservations(TestHelper.TestGuid3); // Exercise the test List <PointCountBeyond50> selectList = ObservationMapper.SelectAllForEvent <PointCountBeyond50>(setupObject.EventId); Assert.AreEqual(1, selectList.Count(), "Does not contain just one object"); PointCountBeyond50 result = selectList[0]; using (IbaUnitTestEntities iba = new IbaUnitTestEntities()) { validateObjectEquality(result, setupObject, iba); } }
public void t_ObservationTypeId() { PointCountBeyond50 target = new PointCountBeyond50(); Guid actual; actual = target.ObservationTypeId; Assert.AreEqual(LookupConstants.ObservationTypePointBeyond50m, actual); }
public void t_CreateNewPointCountObservation() { safnet.iba.Business.Entities.Moles.MSafnetBaseEntity.AllInstances.SetNewId = (SafnetBaseEntity entity) => { return(entity.Id = LookupConstants.LocationTypeParent); }; Guid surveyId = LookupConstants.LocationTypePoint; PointCountBeyond50 actual = PointCountBeyond50.CreateNewPointCountObservation(surveyId); Assert.IsNotNull(actual, "object is null"); Assert.AreEqual(0, actual.Id, "ID not assigned"); Assert.AreEqual(surveyId, actual.EventId, "EventId not assigned"); }
private static void validateObjectEquality(PointCountBeyond50 supplemental, Observation_ado adoPointCountBeyond50, IbaUnitTestEntities iba) { Assert.IsNotNull(adoPointCountBeyond50, "There is no PointCountBeyond50 with the ID to test for"); Assert.IsNotNull(adoPointCountBeyond50.Comments, "ADO Comments are null"); Assert.AreEqual(supplemental.Comments, adoPointCountBeyond50.Comments, "Comments"); Assert.AreEqual(supplemental.EventId, adoPointCountBeyond50.EventId, "EventId"); // ID is now an identity field //Assert.AreEqual(supplemental.Id, adoPointCountBeyond50.ObservationId, "ObservationId"); Assert.AreEqual(supplemental.ObservationTypeId, adoPointCountBeyond50.ObservationTypeId, "ObservationTypeId"); var speciesQuery = from specieses in iba.Species_ado where specieses.AlphaCode == supplemental.SpeciesCode select specieses.SpeciesId; Assert.AreEqual(speciesQuery.First().ToString(), adoPointCountBeyond50.SpeciesId.ToString(), "SpeciesId"); }
public void t_PointCountBeyond50_Save_Update() { Observation_ado setupObject = null; // backdoor data setup DbTestHelper.LoadAdoObjects(delegate(IbaUnitTestEntities iba) { setupObject = new Observation_ado() { Comments = "asdfasdf asdf adsfa dsfads fasdf adsfasd fadsf awefr34fr34r34 ", SpeciesId = new Guid(TestHelper.SPECIES_1_ID), EventId = TestHelper.TestGuid1, ObservationTypeId = _PointCountBeyond50TypeId }; iba.AddToObservation_ado(setupObject); }); List <Observation_ado> extraList = DbTestHelper.LoadExtraneousObservations(TestHelper.TestGuid3); // Setup object to be saved. Change everything except the Id. PointCountBeyond50 testObject = new PointCountBeyond50() { Comments = "hurdy gurdy", SpeciesCode = TestHelper.SPECIES_2_CODE, EventId = setupObject.EventId, Id = setupObject.ObservationId }; // Execute the test ObservationMapper.Update(testObject); // Validate results using (IbaUnitTestEntities iba = new IbaUnitTestEntities()) { var PointCountBeyond50Query = from PointCountBeyond50s in iba.Observation_ado select PointCountBeyond50s; Assert.IsNotNull(PointCountBeyond50Query, "Query result is null"); Assert.AreEqual(extraList.Count() + 1, PointCountBeyond50Query.Count(), "Wrong number of results in query"); Observation_ado adoPointCountBeyond50 = PointCountBeyond50Query.First(x => x.ObservationId == setupObject.ObservationId); validateObjectEquality(testObject, adoPointCountBeyond50, iba); validateExtraObservations(extraList, PointCountBeyond50Query); } }
public void t_PointCountBeyond50_Save_Insert() { //loadSiteVisit(TestHelper.TestGuid1); PointCountBeyond50 supplemental = new PointCountBeyond50() { Comments = "asdfasdf asdf adsfa dsfads fasdf adsfasd fadsf awefr34fr34r34 ", SpeciesCode = TestHelper.SPECIES_1_CODE, EventId = TestHelper.TestGuid1 }; ObservationMapper.Insert(supplemental); using (IbaUnitTestEntities iba = new IbaUnitTestEntities()) { var PointCountBeyond50Query = from PointCountBeyond50s in iba.Observation_ado select PointCountBeyond50s; Assert.IsNotNull(PointCountBeyond50Query, "Query result is null"); Assert.AreEqual(1, PointCountBeyond50Query.Count(), "Wrong number of results in query"); Observation_ado adoPointCountBeyond50 = PointCountBeyond50Query.First(); validateObjectEquality(supplemental, adoPointCountBeyond50, iba); } }
public void t_PointCountBeyond50Constructor() { PointCountBeyond50 target = new PointCountBeyond50(); Assert.IsNotNull(target); }