Ejemplo n.º 1
0
 public override void Setup()
 {
     base.Setup();
     mocks = new MockRepository();
     // save one entry in the database that has a place and a watershed attached
     ClosestWatershedToPlace closestWatershedToPlace = new ClosestWatershedToPlace();
     Place testPlace = new Place();
     testPlace.CgndbKey = "ABCDE";
     testPlace.CreateAndFlush();
     Watershed testWatershed = new Watershed();
     testWatershed.DrainageCode = "01-00-00-00-00-00";
     testWatershed.Place = testPlace;
     testWatershed.CreateAndFlush();
     closestWatershedToPlace.Place = testPlace;
     closestWatershedToPlace.Watershed = testWatershed;
     closestWatershedToPlace.CreateAndFlush();
 }
Ejemplo n.º 2
0
        public void TestBelongsToPlace()
        {
            string drainageCode = "01-02-03-04-05-06";
            string cgndbKey = "ABCDE";

            Place place = new Place();
            place.CgndbKey = cgndbKey;
            place.CreateAndFlush();

            Watershed watershed = new Watershed();
            watershed.DrainageCode = drainageCode;
            watershed.Place = place;
            watershed.CreateAndFlush();

            Watershed dbWatershed = Watershed.Find(drainageCode);
            Assert.IsNotNull(dbWatershed);
            Assert.IsNotNull(dbWatershed.Place);
            Assert.AreEqual(cgndbKey, dbWatershed.Place.CgndbKey);
        }
Ejemplo n.º 3
0
        public void TestBelongsToWatershed()
        {
            int id = 73;
            string drainageCode = "01-00-00-00-00-00";

            Watershed watershed = new Watershed();
            watershed.DrainageCode = drainageCode;
            watershed.CreateAndFlush();

            WaterBody waterbody = new WaterBody();
            waterbody.Id = id;
            waterbody.Watershed = watershed;
            waterbody.CreateAndFlush();

            WaterBody dbWaterbody = WaterBody.Find(id);
            Assert.IsNotNull(dbWaterbody);
            Assert.IsNotNull(dbWaterbody.Watershed);
            Assert.AreEqual(drainageCode, dbWaterbody.Watershed.DrainageCode);
        }
Ejemplo n.º 4
0
        public void TestClosestWatershedToPlace()
        {
            string cgndbKey = "ABCDE";
            Place place = new Place();
            place.CgndbKey = cgndbKey;
            place.CreateAndFlush();

            Watershed watershed = new Watershed();
            watershed.DrainageCode = "01-02-03-04-05-06";
            watershed.Place = place;
            watershed.CreateAndFlush();

            ClosestWatershedToPlace closestWatershedToPlace = new ClosestWatershedToPlace();
            closestWatershedToPlace.Place = place;
            closestWatershedToPlace.Watershed = watershed;
            closestWatershedToPlace.CreateAndFlush();

            Place dbPlace = Place.Find(cgndbKey);
            Assert.IsNotNull(dbPlace);
            Assert.AreEqual(closestWatershedToPlace, place.ClosestWatershedToPlace);
        }
Ejemplo n.º 5
0
        public void TestHasManyWaterBodies()
        {
            string drainageCode = "01-02-03-04-05-06";
            int id1 = 1234;
            int id2 = 5678;

            Watershed watershed = new Watershed();
            watershed.DrainageCode = drainageCode;
            watershed.CreateAndFlush();

            WaterBody waterBody1 = new WaterBody();
            waterBody1.Id = id1;
            waterBody1.Watershed = watershed;
            waterBody1.CreateAndFlush();

            WaterBody waterBody2 = new WaterBody();
            waterBody2.Id = id2;
            waterBody2.Watershed = watershed;
            waterBody2.CreateAndFlush();

            watershed.WaterBodies.Add(waterBody1);
            watershed.WaterBodies.Add(waterBody2);
            watershed.SaveAndFlush();

            Watershed dbWatershed = Watershed.Find(drainageCode);
            Assert.IsNotNull(dbWatershed);
            Assert.AreEqual(2, dbWatershed.WaterBodies.Count);
            Assert.AreEqual(id1, dbWatershed.WaterBodies[0].Id);
            Assert.AreEqual(id2, dbWatershed.WaterBodies[1].Id);
        }
Ejemplo n.º 6
0
        public void TestFindWatershed()
        {
            string drainageCode = "01-02-03-04-05-06";

            Watershed watershed = new Watershed();
            watershed.DrainageCode = drainageCode;
            watershed.CreateAndFlush();

            Watershed dbWatershed = Watershed.Find(drainageCode);
            Assert.IsNotNull(dbWatershed);
            Assert.AreEqual(drainageCode, dbWatershed.DrainageCode);
        }