/// <summary> /// Tests a simple relation read/write operation. /// </summary> /// <param name="cache"></param> public void DoOsmDataCacheTestRelation(OsmDataCache cache) { Relation relation = Relation.Create(1, new TagsCollection( Tag.Create("relation", "yes")), RelationMember.Create(1, "something", OsmGeoType.Node)); // test invalid stuff. Assert.Throws <ArgumentNullException>(() => cache.AddRelation(null)); Assert.Throws <Exception>(() => cache.AddRelation(new Relation())); Assert.IsNull(cache.GetRelation(relation.Id.Value)); cache.AddRelation(relation); Assert.IsTrue(cache.ContainsRelation(relation.Id.Value)); Relation readRelation = cache.GetRelation(relation.Id.Value); Assert.IsNotNull(readRelation); Assert.AreEqual(1, readRelation.Id.Value); Assert.IsNotNull(relation.Tags); Assert.AreEqual(1, relation.Tags.Count); Assert.AreEqual("yes", relation.Tags["relation"]); Assert.IsTrue(cache.TryGetRelation(relation.Id.Value, out readRelation)); Assert.IsNotNull(readRelation); Assert.AreEqual(1, readRelation.Id.Value); Assert.IsNotNull(relation.Tags); Assert.AreEqual(1, relation.Tags.Count); Assert.AreEqual("yes", relation.Tags["relation"]); Assert.IsTrue(cache.RemoveRelation(relation.Id.Value)); Assert.IsFalse(cache.ContainsRelation(relation.Id.Value)); Assert.IsFalse(cache.RemoveRelation(relation.Id.Value)); }