public void SavesSite() { var importedTrip = new ImportedTripStub { Date = DateTime.Now.AddDays(1), Website = "http://www.example.com" }; var importedSite = new ImportedSiteStub(importedTrip) { Comments = "Comments", Coordinates = Coordinates.Create(1, 2), County = "County", MakeOwnershipContactInfoPublic = true, Name = "Name", OwnershipContactInfo = "OwnershipContactInfo", OwnershipType = "OwnershipType", State = Repositories.Locations.FindStateById(50) }; var site = Site.Create(importedSite); site.Visits[0].SetPrivatePropertyValue("ImportingTrip", null); using (var uow = UnitOfWork.Begin()) { Repositories.Sites.Save(site); UnitOfWork.Flush(); UnitOfWork.Refresh(site); Assert.IsNotNull(site); Assert.IsNotNull(site.Visits); Assert.AreEqual(1, site.Visits.Count); uow.Rollback(); } }
public void CreatesSite() { var importedTrip = new ImportedTripStub { Date = DateTime.Now }; var importedSite = new ImportedSiteStub(importedTrip) { Comments = "Comments", Coordinates = Coordinates.Create(1, 2), Name = "Name", County = "County", MakeOwnershipContactInfoPublic = true, OwnershipContactInfo = "OwnershipContactInfo", OwnershipType = "OwnershipType", State = new StateStub("State") }; var site = Site.Create(importedSite); Assert.AreEqual(1, site.Visits.Count); Assert.AreEqual("Comments", site.Visits[0].Comments); Assert.AreEqual(Coordinates.Create(1, 2), site.Coordinates); Assert.AreEqual("Name", site.Name); Assert.AreEqual("County", site.County); Assert.IsTrue(site.MakeOwnershipContactInfoPublic); Assert.AreEqual("OwnershipContactInfo", site.OwnershipContactInfo); Assert.AreEqual("OwnershipType", site.OwnershipType); Assert.AreEqual("State", site.State.Name); }
public void SavesTree() { var importedTrip = new ImportedTripStub { Date = DateTime.Now.AddDays(1) }; var importedSite = new ImportedSiteStub(importedTrip); var tree = Tree.Create(new ImportedTreeStub(importedSite) { CommonName = "CommonName", ScientificName = "ScientificName", Height = 1, HeightMeasurementMethod = TMD.Model.Imports.TreeHeightMeasurementMethod.ClinometerLaserRangefinderSine, Girth = 2, CrownSpread = 3, Coordinates = Coordinates.Create(4, 5), Elevation = Elevation.Create(6), GeneralComments = "GeneralComments" }); tree.Measurements[0].SetPrivatePropertyValue("ImportingTrip", null); using (var uow = UnitOfWork.Begin()) { Repositories.Trees.Save(tree); UnitOfWork.Flush(); UnitOfWork.Refresh(tree); Assert.IsNotNull(tree); Assert.IsNotNull(tree.Measurements); Assert.AreEqual(1, tree.Measurements.Count); Assert.IsNotNull(tree.Species); uow.Rollback(); } }
public void DeterminesWhetherToMergeTrees() { var importedTrip = new ImportedTripStub { Date = DateTime.Now }; var importedSite = new ImportedSiteStub(importedTrip); var tree1 = Tree.Create(new ImportedTreeStub(importedSite) { CommonName = "CommonName1", ScientificName = "ScientificName1", Coordinates = Coordinates.Create(1, 2) }); var tree2 = Tree.Create(new ImportedTreeStub(importedSite) { CommonName = "CommonName1", ScientificName = "ScientificName1", Coordinates = Coordinates.Create(3, 4) }); Assert.IsFalse(tree1.ShouldMerge(tree2)); Assert.IsFalse(tree2.ShouldMerge(tree1)); var tree3 = Tree.Create(new ImportedTreeStub(importedSite) { CommonName = "CommonName1", ScientificName = "ScientificName1", Coordinates = Coordinates.Create(1, 2) }); Assert.IsTrue(tree3.ShouldMerge(tree1)); Assert.IsTrue(tree1.ShouldMerge(tree3)); Assert.IsFalse(tree3.ShouldMerge(tree2)); Assert.IsFalse(tree2.ShouldMerge(tree3)); }
public void CreatesTree() { var importedTrip = new ImportedTripStub { Date = DateTime.Now }; var importedSite = new ImportedSiteStub(importedTrip); var importedTree = new ImportedTreeStub(importedSite) { CommonName = "CommonName", ScientificName = "ScientificName", Height = 1, HeightMeasurementMethod = TMD.Model.Imports.TreeHeightMeasurementMethod.ClinometerLaserRangefinderSine, Girth = 2, CrownSpread = 3, Coordinates = Coordinates.Create(4, 5), Elevation = Elevation.Create(6), GeneralComments = "GeneralComments" }; var tree = Tree.Create(importedTree); Assert.AreEqual(1, tree.Measurements.Count); Assert.AreEqual("Commonname", tree.CommonName); Assert.AreEqual("Scientificname", tree.ScientificName); Assert.AreEqual(1, tree.Height); Assert.AreEqual(TMD.Model.Imports.TreeHeightMeasurementMethod.ClinometerLaserRangefinderSine, tree.HeightMeasurementMethod); Assert.AreEqual(2, tree.Girth); Assert.AreEqual(3, tree.CrownSpread); Assert.AreEqual(Coordinates.Create(4, 5), tree.Coordinates); Assert.AreEqual(Elevation.Create(6), tree.Elevation); Assert.AreEqual(2f, tree.ENTSPTS); Assert.AreEqual(0.04f, tree.ENTSPTS2); Assert.AreEqual("GeneralComments", tree.Measurements[0].GeneralComments); }
public void MergresTrees() { var importedTrip1 = new ImportedTripStub { Date = DateTime.Now.AddDays(1) }; var importedSite1 = new ImportedSiteStub(importedTrip1); var tree1 = Tree.Create(new ImportedTreeStub(importedSite1) { CommonName = "CommonName", ScientificName = "ScientificName", Height = 1, HeightMeasurementMethod = TMD.Model.Imports.TreeHeightMeasurementMethod.ClinometerLaserRangefinderSine, Girth = 2, CrownSpread = 3, Coordinates = Coordinates.Create(4, 5), Elevation = Elevation.Create(6) }); var importedTrip2 = new ImportedTripStub { Date = DateTime.Now }; var importedSite2 = new ImportedSiteStub(importedTrip2); var tree2 = Tree.Create(new ImportedTreeStub(importedSite2) { CommonName = "CommonName", ScientificName = "ScientificName", Height = 10, HeightMeasurementMethod = TMD.Model.Imports.TreeHeightMeasurementMethod.FormalTransitTotalStationSurvey, Girth = 20, CrownSpread = 30, Coordinates = Coordinates.Create(4, 5), Elevation = Elevation.Create(60) }); Assert.IsTrue(tree1.ShouldMerge(tree2)); tree2.Merge(tree1); Assert.AreEqual(2, tree2.Measurements.Count); Assert.AreEqual(1, tree2.Height); Assert.AreEqual(TMD.Model.Imports.TreeHeightMeasurementMethod.ClinometerLaserRangefinderSine, tree2.HeightMeasurementMethod); Assert.AreEqual(2, tree2.Girth); Assert.AreEqual(3, tree2.CrownSpread); Assert.AreEqual(Elevation.Create(6), tree2.Elevation); Assert.AreEqual(2f, tree2.ENTSPTS); Assert.AreEqual(0.04f, tree2.ENTSPTS2); }
public void MergesSites() { var state = new StateStub("State"); var importedTrip1 = new ImportedTripStub { Date = DateTime.Now.AddDays(1) }; var site1 = Site.Create(new ImportedSiteStub(importedTrip1) { Coordinates = Coordinates.Create(1, 2), County = "County", Name = "Name", State = state, MakeOwnershipContactInfoPublic = true, OwnershipContactInfo = "OwnershipContactInfo1", OwnershipType = "OwnershipType1", }); var importedTrip2 = new ImportedTripStub { Date = DateTime.Now }; var site2 = Site.Create(new ImportedSiteStub(importedTrip2) { Coordinates = Coordinates.Create(1, 2), County = "County", Name = "Name", State = state, MakeOwnershipContactInfoPublic = false, OwnershipContactInfo = "OwnershipContactInfo2", OwnershipType = "OwnershipType2", }); Assert.IsTrue(site1.ShouldMerge(site2)); site2.Merge(site1); Assert.AreEqual(2, site2.Visits.Count); Assert.IsTrue(site2.MakeOwnershipContactInfoPublic); Assert.AreEqual("OwnershipContactInfo1", site2.OwnershipContactInfo); Assert.AreEqual("OwnershipType1", site2.OwnershipType); }
public void DeterminesWhetherToMergeSites() { var state = new StateStub("State"); var importedTrip = new ImportedTripStub { Date = DateTime.Now }; var site1 = Site.Create(new ImportedSiteStub(importedTrip) { Coordinates = Coordinates.Create(1, 2), County = "County", Name = "Name", State = state }); var site2 = Site.Create(new ImportedSiteStub(importedTrip) { Coordinates = Coordinates.Create(1.3f, 1.7f), County = "County", Name = "Name", State = state }); Assert.IsFalse(site1.ShouldMerge(site2)); Assert.IsFalse(site2.ShouldMerge(site1)); var site3 = Site.Create(new ImportedSiteStub(importedTrip) { Coordinates = Coordinates.Create(1, 2), County = "County", Name = "Name", State = state }); Assert.IsTrue(site3.ShouldMerge(site1)); Assert.IsTrue(site1.ShouldMerge(site3)); Assert.IsFalse(site3.ShouldMerge(site2)); Assert.IsFalse(site2.ShouldMerge(site3)); }
public void FindsByProximity() { var state = Repositories.Locations.FindStateById(50); var importedTrip = new ImportedTripStub { Date = DateTime.Now.AddDays(1), Website = "http://www.example.com" }; var site1 = Site.Create(new ImportedSiteStub(importedTrip) { Coordinates = Coordinates.Create(1, 2), County = "County 1", Name = "Name 1", Comments = "Comments 1", OwnershipContactInfo = "OwnershipContactInfo 1", OwnershipType = "OwnershipType 1", State = state }); site1.Visits[0].SetPrivatePropertyValue("ImportingTrip", null); var site2 = Site.Create(new ImportedSiteStub(importedTrip) { Coordinates = Coordinates.Create(1.1f, 2.1f), County = "County 2", Name = "Name 2", Comments = "Comments 2", OwnershipContactInfo = "OwnershipContactInfo 2", OwnershipType = "OwnershipType 2", State = state }); site2.Visits[0].SetPrivatePropertyValue("ImportingTrip", null); var site3 = Site.Create(new ImportedSiteStub(importedTrip) { Coordinates = Coordinates.Create(0.9f, 1.9f), County = "County 3", Name = "Name 3", Comments = "Comments 3", OwnershipContactInfo = "OwnershipContactInfo 3", OwnershipType = "OwnershipType 3", State = state }); site3.Visits[0].SetPrivatePropertyValue("ImportingTrip", null); var site4 = Site.Create(new ImportedSiteStub(importedTrip) { Coordinates = Coordinates.Create(3, 4), County = "County 4", Name = "Name 4", Comments = "Comments 4", OwnershipContactInfo = "OwnershipContactInfo 4", OwnershipType = "OwnershipType 4", State = state }); site4.Visits[0].SetPrivatePropertyValue("ImportingTrip", null); using (var uow = UnitOfWork.Begin()) { Repositories.Sites.Save(site1); Repositories.Sites.Save(site2); Repositories.Sites.Save(site3); Repositories.Sites.Save(site4); UnitOfWork.Flush(); IList <Site> sites = Repositories.Sites.ListByProximity(Coordinates.Create(1, 2), Site.CoordinateMinutesEquivalenceProximity); Assert.IsNotNull(sites); Assert.AreEqual(3, sites.Count); Assert.IsTrue(sites.Contains(site1)); Assert.IsTrue(sites.Contains(site2)); Assert.IsTrue(sites.Contains(site3)); Assert.IsFalse(sites.Contains(site4)); uow.Rollback(); } }