/// <summary> /// Tests a simple way read/write operation. /// </summary> public void DoOsmDataCacheTestWay(OsmDataCache cache) { Way way = Way.Create(1, new TagsCollection( Tag.Create("way", "yes")), 1, 2); // test invalid stuff. Assert.Throws<ArgumentNullException>(() => cache.AddWay(null)); Assert.Throws<Exception>(() => cache.AddWay(new Way())); Assert.IsNull(cache.GetWay(way.Id.Value)); cache.AddWay(way); Assert.IsTrue(cache.ContainsWay(way.Id.Value)); Way readWay = cache.GetWay(way.Id.Value); Assert.IsNotNull(readWay); Assert.AreEqual(1, readWay.Id.Value); Assert.IsNotNull(way.Tags); Assert.AreEqual(1, way.Tags.Count); Assert.AreEqual("yes", way.Tags["way"]); Assert.IsTrue(cache.TryGetWay(way.Id.Value, out readWay)); Assert.IsNotNull(readWay); Assert.AreEqual(1, readWay.Id.Value); Assert.IsNotNull(way.Tags); Assert.AreEqual(1, way.Tags.Count); Assert.AreEqual("yes", way.Tags["way"]); Assert.IsTrue(cache.RemoveWay(way.Id.Value)); Assert.IsFalse(cache.ContainsWay(way.Id.Value)); Assert.IsFalse(cache.RemoveWay(way.Id.Value)); }
/// <summary> /// Tests the clear functionality on the datacache. /// </summary> /// <param name="cache"></param> public void DoOsmDataCacheTestClear(OsmDataCache cache) { Node node = Node.Create(1, new TagsCollection( Tag.Create("node", "yes")), 1, 2); Way way = Way.Create(1, new TagsCollection( Tag.Create("way", "yes")), 1, 2); Relation relation = Relation.Create(1, new TagsCollection( Tag.Create("relation", "yes")), RelationMember.Create(1, "something", OsmGeoType.Node)); cache.AddNode(node); cache.AddWay(way); cache.AddRelation(relation); Assert.IsTrue(cache.ContainsNode(node.Id.Value)); Assert.IsTrue(cache.ContainsWay(way.Id.Value)); Assert.IsTrue(cache.ContainsRelation(relation.Id.Value)); cache.Clear(); Assert.IsFalse(cache.ContainsNode(node.Id.Value)); Assert.IsFalse(cache.ContainsWay(way.Id.Value)); Assert.IsFalse(cache.ContainsRelation(relation.Id.Value)); }