Exemple #1
0
        public void APITestNodeCreateGetUpdate()
        {
            // intialize the connection.
            var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/",
                                                "osmsharp", "osmsharp");

            // open a changeset.
            apiInstance.ChangeSetOpen("Simple Node Creation Test");

            // initialize the node.
            var node = new Node();

            node.Latitude  = -0.494497;
            node.Longitude = -24.119325;
            node.Tags      = new SimpleTagsCollection();
            node.Tags.Add("type", "testnode");
            node.Visible = true;

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

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

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

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

            // open new changeset.
            apiInstance.ChangeSetOpen("Simple Node Update Test");

            // get the node.
            Node apiNode = apiInstance.NodeGet(node.Id.Value);

            apiNode.Tags.Add("another_tag", "test adding a tag!");
            apiInstance.NodeUpdate(apiNode);

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

            // get the api node.
            apiNode = apiInstance.NodeGet(node.Id.Value);

            Assert.AreEqual(2, apiNode.Tags.Count);
            Assert.IsTrue(apiNode.Tags.ContainsKey("another_tag"));
            Assert.AreEqual("test adding a tag!", apiNode.Tags["another_tag"]);
        }
Exemple #2
0
        public void APITestNodeCreateGetDelete()
        {
            // intialize the connection.
            var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/",
                                                "osmsharp", "osmsharp");

            // open a changeset.
            apiInstance.ChangeSetOpen("Simple Node Creation Test");

            // initialize the node.
            var node = new Node();

            node.Latitude  = -0.494497;
            node.Longitude = -24.119325;
            node.Tags      = new SimpleTagsCollection();
            node.Tags.Add("type", "testnode");
            node.Visible = true;

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

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

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

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

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

            // open new changeset.
            apiInstance.ChangeSetOpen("Simple Node Delete Test");

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

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

            // get the node.
            Node apiNode = apiInstance.NodeGet(node.Id.Value);

            Assert.IsNull(apiNode);
        }
Exemple #3
0
        public void APITestNodeCreateGet()
        {
            // intialize the connection.
            var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/",
                                                "osmsharp", "osmsharp");

            // open a changeset.
            long changesetId = apiInstance.ChangeSetOpen("Simple Node Creation Test");

            // initialize the node.
            var node = new Node();

            node.Latitude  = -0.494497;
            node.Longitude = -24.119325;
            node.Tags      = new SimpleTagsCollection();
            node.Tags.Add("type", "testnode");
            node.Visible = true;

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

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

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

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

            // get the node from the api.
            Node nodeAPI = apiInstance.NodeGet(node.Id.Value);

            Assert.AreEqual(node.Latitude, nodeAPI.Latitude);
            Assert.AreEqual(node.Longitude, nodeAPI.Longitude);
            Assert.AreEqual(node.Tags.Count, nodeAPI.Tags.Count);
            Assert.AreEqual(node.Visible, nodeAPI.Visible);
            Assert.IsTrue(nodeAPI.ChangeSetId.HasValue);
            Assert.AreEqual(changesetId, nodeAPI.ChangeSetId.Value);
        }