예제 #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 TagsCollection();
            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"]);
        }