public void TestAddRelationAndMembers() { Way testWay = new Way(); testWay.Id = 1; testWay.Nodes = new List <long>(); testWay.Nodes.Add(1); testWay.Nodes.Add(2); Node node1 = new Node(); node1.Id = 1; node1.Longitude = 0; node1.Latitude = 0; Node node2 = new Node(); node2.Id = 2; node2.Longitude = 0; node2.Latitude = 0; Relation relationAsMember = new Relation(); relationAsMember.Id = 2; Relation relation = new Relation(); relation.Id = 1; relation.Members = new List <RelationMember>(); relation.Members.Add(new RelationMember() { MemberId = 1, MemberRole = "node", MemberType = OsmGeoType.Node }); relation.Members.Add(new RelationMember() { MemberId = 2, MemberRole = "node", MemberType = OsmGeoType.Node }); relation.Members.Add(new RelationMember() { MemberId = 1, MemberRole = "way", MemberType = OsmGeoType.Way }); relation.Members.Add(new RelationMember() { MemberId = 2, MemberRole = "relation", MemberType = OsmGeoType.Relation }); var source = new MemoryDataSource(); source.AddRelation(relation); // test positive cases. IList <Relation> resultRelations = source.GetRelationsFor(node1); Assert.IsNotNull(resultRelations); Assert.AreEqual(1, resultRelations.Count); Assert.AreEqual(relation, resultRelations[0]); resultRelations = source.GetRelationsFor(node2); Assert.IsNotNull(resultRelations); Assert.AreEqual(1, resultRelations.Count); Assert.AreEqual(relation, resultRelations[0]); resultRelations = source.GetRelationsFor(testWay); Assert.IsNotNull(resultRelations); Assert.AreEqual(1, resultRelations.Count); Assert.AreEqual(relation, resultRelations[0]); resultRelations = source.GetRelationsFor(relationAsMember); Assert.IsNotNull(resultRelations); Assert.AreEqual(1, resultRelations.Count); Assert.AreEqual(relation, resultRelations[0]); // test negative cases. resultRelations = source.GetRelationsFor(OsmGeoType.Node, 10000); Assert.IsNotNull(resultRelations); Assert.AreEqual(0, resultRelations.Count); resultRelations = source.GetRelationsFor(OsmGeoType.Way, 10000); Assert.IsNotNull(resultRelations); Assert.AreEqual(0, resultRelations.Count); resultRelations = source.GetRelationsFor(OsmGeoType.Relation, 10000); Assert.IsNotNull(resultRelations); Assert.AreEqual(0, resultRelations.Count); }