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(); }
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); }
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); }
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); }
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); }
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); }