Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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));
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }