public void APITestWayCreateGetDelete() { // intialize the connection. APIConnection api_instance = new APIConnection("http://api06.dev.openstreetmap.org/", "osmsharp", "osmsharp"); // open a changeset. long changeset_id = api_instance.ChangeSetOpen("Simple Way Creation Test"); // initialize the way. SimpleWay way = new SimpleWay(); way.Tags = new Dictionary<string, string>(); way.Tags.Add("type", "testway"); way.Nodes = new List<long>(); way.Visible = true; // initialize the nodes. SimpleNode node = new SimpleNode(); node.Latitude = -0.494497; node.Longitude = -24.119325; node.Tags = new Dictionary<string, string>(); node.Tags.Add("type", "testnode1"); node.Visible = true; node = api_instance.NodeCreate(node); way.Nodes.Add(node.Id.Value); node = new SimpleNode(); node.Latitude = -0.494497 + 0.0001f; node.Longitude = -24.119325 + 0.0001f; node.Tags = new Dictionary<string, string>(); node.Tags.Add("type", "testnode2"); node.Visible = true; node = api_instance.NodeCreate(node); way.Nodes.Add(node.Id.Value); // save the way. way = api_instance.WayCreate(way); // close the changeset. api_instance.ChangeSetClose(); // check if the id now has a value. Assert.IsTrue(way.Id.HasValue); // get the new way id. long way_id = way.Id.Value; // get the way again: a way can only be deleted using the correct changesetid and version. way = api_instance.WayGet(way.Id.Value); // open new changeset. changeset_id = api_instance.ChangeSetOpen("Simple Way Delete Test"); // get the way. api_instance.WayDelete(way); // close the current changeset. api_instance.ChangeSetClose(); // get the way. SimpleWay api_way = api_instance.WayGet(way.Id.Value); Assert.IsNull(api_way); }
public void APITestWayCreateGetUpdate() { // intialize the connection. APIConnection api_instance = new APIConnection("http://api06.dev.openstreetmap.org/", "osmsharp", "osmsharp"); // open a changeset. long changeset_id = api_instance.ChangeSetOpen("Simple Way Creation Test"); // initialize the way. SimpleWay way = new SimpleWay(); way.Tags = new Dictionary<string, string>(); way.Tags.Add("type", "testway"); way.Nodes = new List<long>(); way.Visible = true; // initialize the nodes. SimpleNode node = new SimpleNode(); node.Latitude = -0.494497; node.Longitude = -24.119325; node.Tags = new Dictionary<string, string>(); node.Tags.Add("type", "testnode1"); node.Visible = true; node = api_instance.NodeCreate(node); way.Nodes.Add(node.Id.Value); node = new SimpleNode(); node.Latitude = -0.494497 + 0.0001f; node.Longitude = -24.119325 + 0.0001f; node.Tags = new Dictionary<string, string>(); node.Tags.Add("type", "testnode2"); node.Visible = true; node = api_instance.NodeCreate(node); way.Nodes.Add(node.Id.Value); // save the way. way = api_instance.WayCreate(way); // close the changeset. api_instance.ChangeSetClose(); // check if the id now has a value. Assert.IsTrue(way.Id.HasValue); // get the new way id. long way_id = way.Id.Value; // open new changeset. changeset_id = api_instance.ChangeSetOpen("Simple Way Update Test"); // get the way. SimpleWay api_way = api_instance.WayGet(way.Id.Value); api_way.Tags.Add("another_tag", "test adding a tag!"); api_instance.WayUpdate(api_way); // close the current changeset. api_instance.ChangeSetClose(); // get the api way. api_way = api_instance.WayGet(way.Id.Value); Assert.AreEqual(2, api_way.Tags.Count); Assert.IsTrue(api_way.Tags.ContainsKey("another_tag")); Assert.AreEqual("test adding a tag!", api_way.Tags["another_tag"]); }
public void APITestWayCreateGet() { // intialize the connection. APIConnection api_instance = new APIConnection("http://api06.dev.openstreetmap.org/", "osmsharp", "osmsharp"); // open a changeset. long changeset_id = api_instance.ChangeSetOpen("Simple Way Creation Test"); // initialize the way. SimpleWay way = new SimpleWay(); way.Tags = new Dictionary<string, string>(); way.Tags.Add("type", "testway"); way.Nodes = new List<long>(); way.Visible = true; // initialize the nodes. SimpleNode node = new SimpleNode(); node.Latitude = -0.494497; node.Longitude = -24.119325; node.Tags = new Dictionary<string, string>(); node.Tags.Add("type", "testnode1"); node.Visible = true; node = api_instance.NodeCreate(node); way.Nodes.Add(node.Id.Value); node = new SimpleNode(); node.Latitude = -0.494497 + 0.0001f; node.Longitude = -24.119325 + 0.0001f; node.Tags = new Dictionary<string, string>(); node.Tags.Add("type", "testnode2"); node.Visible = true; node = api_instance.NodeCreate(node); way.Nodes.Add(node.Id.Value); // save the way. way = api_instance.WayCreate(way); // close the changeset. api_instance.ChangeSetClose(); // check if the id now has a value. Assert.IsTrue(way.Id.HasValue); // get the new way id. long way_id = way.Id.Value; // get the way from the api. SimpleWay way_api = api_instance.WayGet(way.Id.Value); Assert.AreEqual(way_id, way_api.Id.Value); Assert.AreEqual(way.Tags.Count, way_api.Tags.Count); Assert.AreEqual(way.Visible, way_api.Visible); Assert.IsTrue(way_api.ChangeSetId.HasValue); Assert.AreEqual(changeset_id, way_api.ChangeSetId.Value); Assert.AreEqual(way.Nodes[0], way_api.Nodes[0]); Assert.AreEqual(way.Nodes[1], way_api.Nodes[1]); }