Esempio n. 1
0
        public void APITestNodeCreateGetDelete()
        {
            // 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 Node Creation Test");

            // initialize the node.
            SimpleNode node = new SimpleNode();
            node.Latitude = -0.494497;
            node.Longitude = -24.119325;
            node.Tags = new Dictionary<string, string>();
            node.Tags.Add("type", "testnode");
            node.Visible = true;

            // save the node.
            node = api_instance.NodeCreate(node);

            // close the changeset.
            api_instance.ChangeSetClose();

            // check if the id now has a value.
            Assert.IsTrue(node.Id.HasValue);

            // get the new node id.
            long node_id = node.Id.Value;

            // get the node again: a node can only be deleted using the correct changesetid and version.
            node = api_instance.NodeGet(node.Id.Value);

            // open new changeset.
            changeset_id = api_instance.ChangeSetOpen("Simple Node Delete Test");

            // get the node.
            api_instance.NodeDelete(node);

            // close the current changeset.
            api_instance.ChangeSetClose();

            // get the node.
            SimpleNode api_node = api_instance.NodeGet(node.Id.Value);
            Assert.IsNull(api_node);
        }
Esempio n. 2
0
        public void APITestNodeCreateGetUpdate()
        {
            // 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 Node Creation Test");

            // initialize the node.
            SimpleNode node = new SimpleNode();
            node.Latitude = -0.494497;
            node.Longitude = -24.119325;
            node.Tags = new Dictionary<string, string>();
            node.Tags.Add("type", "testnode");
            node.Visible = true;

            // save the node.
            node = api_instance.NodeCreate(node);

            // close the changeset.
            api_instance.ChangeSetClose();

            // check if the id now has a value.
            Assert.IsTrue(node.Id.HasValue);

            // get the new node id.
            long node_id = node.Id.Value;

            // open new changeset.
            changeset_id = api_instance.ChangeSetOpen("Simple Node Update Test");

            // get the node.
            SimpleNode api_node = api_instance.NodeGet(node.Id.Value);
            api_node.Tags.Add("another_tag", "test adding a tag!");
            api_instance.NodeUpdate(api_node);

            // close the current changeset.
            api_instance.ChangeSetClose();

            // get the api node.
            api_node = api_instance.NodeGet(node.Id.Value);

            Assert.AreEqual(2, api_node.Tags.Count);
            Assert.IsTrue(api_node.Tags.ContainsKey("another_tag"));
            Assert.AreEqual("test adding a tag!", api_node.Tags["another_tag"]);
        }
Esempio n. 3
0
        public void APITestNodeCreateGet()
        {
            // 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 Node Creation Test");

            // initialize the node.
            SimpleNode node = new SimpleNode();
            node.Latitude = -0.494497;
            node.Longitude = -24.119325;
            node.Tags = new Dictionary<string, string>();
            node.Tags.Add("type", "testnode");
            node.Visible = true;

            // save the node.
            node = api_instance.NodeCreate(node);

            // close the changeset.
            api_instance.ChangeSetClose();

            // check if the id now has a value.
            Assert.IsTrue(node.Id.HasValue);

            // get the new node id.
            long node_id = node.Id.Value;

            // get the node from the api.
            SimpleNode node_api = api_instance.NodeGet(node.Id.Value);
            Assert.AreEqual(node.Latitude, node_api.Latitude);
            Assert.AreEqual(node.Longitude, node_api.Longitude);
            Assert.AreEqual(node.Tags.Count, node_api.Tags.Count);
            Assert.AreEqual(node.Visible, node_api.Visible);
            Assert.IsTrue(node_api.ChangeSetId.HasValue);
            Assert.AreEqual(changeset_id, node_api.ChangeSetId.Value);
        }