public string MapLink(InteractiveMap map, IDictionary anchorAttributes) { if (anchorAttributes == null) anchorAttributes = DictHelper.Create(); return String.Format("<a href=\"{0}?id={1}\" {2}>{3}</a>", Config.MapApplicationUrl, map.Id, GetAttributes(anchorAttributes), map.Title); }
public void TestFind() { string title = "Test Map"; InteractiveMap map = new InteractiveMap(); map.Title = title; map.CreateAndFlush(); InteractiveMap dbMap = InteractiveMap.Find(map.Id); Assert.IsNotNull(dbMap); Assert.AreEqual(title, dbMap.Title); }
/// <summary> /// Basic constructor /// </summary> public MapInitializer(Map map, InteractiveMap interactiveMap) { if (map == null) throw new ArgumentNullException("map"); _map = map; _interactiveMap = interactiveMap; properties = GlobalApplication.ContainerAccessor.Container .Resolve<InitializerProperties>("init.properties"); logger = GlobalApplication .CreateLogger(typeof(MapInitializer)); }
public void TestFindAllBasinMaps() { InteractiveMap[] testMaps = new InteractiveMap[7]; for (int i = 0; i < testMaps.Length; i++) { testMaps[i] = new InteractiveMap(); testMaps[i].Title = "Test Map #" + i; testMaps[i].Create(); } testMaps[1].IsBasinMap = true; testMaps[3].IsBasinMap = true; testMaps[5].IsBasinMap = true; Flush(); Assert.AreEqual(3, InteractiveMap.FindAllBasinMaps().Count); }
public void TestFindAllByQuery() { Assert.Ignore(); string query = "%Test Query%"; InteractiveMap[] maps = new InteractiveMap[5]; for (int i = 0; i < maps.Length; i++) { maps[i] = new InteractiveMap(); maps[i].Title = query + " will match this interactive map: #" + i.ToString(); maps[i].CreateAndFlush(); } IList<InteractiveMap> mapList = InteractiveMap.FindAllByQuery(query); Assert.IsNotNull(mapList); Assert.AreEqual(maps.Length, mapList.Count); }
public void TestFindByTitle() { string testTitle = "title that matches exactly"; InteractiveMap matchingMap = new InteractiveMap(); matchingMap.Title = testTitle; matchingMap.Create(); InteractiveMap almostExact = new InteractiveMap(); almostExact.Title = testTitle + " but not quite"; almostExact.Create(); InteractiveMap notEvenClose = new InteractiveMap(); notEvenClose.Title = "not even close to the title"; notEvenClose.Create(); Flush(); Assert.AreEqual(matchingMap, InteractiveMap.FindByTitle(testTitle)); }
public void TestRelatedInteractiveMapsWhenIsWithinBasin() { Assert.Ignore(); string query = "place name is the default query"; Place place = new Place(); place.Name = query; ClosestWatershedToPlace cwtp = mocks.CreateMock<ClosestWatershedToPlace>(); place.ClosestWatershedToPlace = cwtp; Expect.Call(cwtp.IsWithinBasin()).Return(true).Repeat.AtLeastOnce(); mocks.ReplayAll(); InteractiveMap[] interactiveMaps = new InteractiveMap[3]; for (int i = 0; i < interactiveMaps.Length; i++) { interactiveMaps[i] = new InteractiveMap(); interactiveMaps[i].Title = "Interactive Map where " + query + ": #" + i.ToString(); interactiveMaps[i].IsBasinMap = (i % 2) == 0 ? true : false; // even to true, odd to false interactiveMaps[i].CreateAndFlush(); } Assert.IsTrue(place.IsWithinBasin()); Assert.AreEqual(2, place.RelatedInteractiveMaps.Count); mocks.VerifyAll(); }
public string MapLink(InteractiveMap map) { return MapLink(map, null); }
public void TestRelatedInteractiveMapsWhenIsWithinBasin() { Assert.Ignore(); string query = "place name is the default query"; Watershed watershed = new Watershed(); watershed.Name = query; watershed.DrainageCode = "01-02-03-04-05-06"; InteractiveMap[] interactiveMaps = new InteractiveMap[3]; for (int i = 0; i < interactiveMaps.Length; i++) { interactiveMaps[i] = new InteractiveMap(); interactiveMaps[i].Title = "Interactive Map where " + query + ": #" + i.ToString(); interactiveMaps[i].IsBasinMap = (i % 2) == 0 ? true : false; // even to true, odd to false interactiveMaps[i].CreateAndFlush(); } Assert.IsTrue(watershed.IsWithinBasin()); Assert.AreEqual(2, watershed.RelatedInteractiveMaps.Count); }
public void TestRelatedInteractiveMapsWhenIsWithinBasin() { Assert.Ignore(); string query = "place name is the default query"; WaterBody waterbody = new WaterBody(); waterbody.Name = query; Watershed watershed = mocks.CreateMock<Watershed>(); waterbody.Watershed = watershed; Expect.Call(watershed.IsWithinBasin()).Return(true).Repeat.AtLeastOnce(); mocks.ReplayAll(); InteractiveMap[] interactiveMaps = new InteractiveMap[3]; for (int i = 0; i < interactiveMaps.Length; i++) { interactiveMaps[i] = new InteractiveMap(); interactiveMaps[i].Title = "Interactive Map where " + query + ": #" + i.ToString(); interactiveMaps[i].IsBasinMap = (i % 2) == 0 ? true : false; // even to true, odd to false interactiveMaps[i].CreateAndFlush(); } Assert.IsTrue(waterbody.IsWithinBasin()); Assert.AreEqual(2, waterbody.RelatedInteractiveMaps.Count); mocks.VerifyAll(); }
public void TestProperties() { InteractiveMap map = new InteractiveMap(); Dictionary<string, object> properties = new Dictionary<string, object>(); properties.Add("Title", "New Map Title"); properties.Add("Id", 3); properties.Add("IsBasinMap", true); properties.Add("ThumbnailUrl", "http://location.to.thumbnail"); properties.Add("LargeThumbnailUrl", "http://location.to.larger.thumbnail"); properties.Add("CreatedAt", DateTime.Now); properties.Add("UpdatedAt", DateTime.Now); TestHelper.ErrorSummary summary = TestHelper.TestProperties(map, properties); Assert.IsEmpty(summary, "The following errors occured while testing InteractiveMap properties:\n" + summary.GetSummary()); }
public void TestGetMetadata() { InteractiveMap map = new InteractiveMap(); map.Title = "Test Map"; map.CreateAndFlush(); Metadata metadata = new Metadata(); metadata.Owner = map; metadata.CreateAndFlush(); InteractiveMap dbMap = InteractiveMap.Find(map.Id); Assert.AreEqual(metadata, map.GetMetadata()); }
public void TestFindByTitleWhenTwoTitlesMatch() { string testTitle = "title that matches exactly"; InteractiveMap firstMatchingMap = new InteractiveMap(); firstMatchingMap.Title = testTitle; firstMatchingMap.Create(); InteractiveMap secondMatchingMap = new InteractiveMap(); secondMatchingMap.Title = testTitle; secondMatchingMap.Create(); Flush(); InteractiveMap returnedMap = InteractiveMap.FindByTitle(testTitle); Assert.AreEqual(firstMatchingMap, returnedMap); Assert.AreNotEqual(secondMatchingMap, returnedMap); }