Exemple #1
0
        public void TestSerialize()
        {
            ItemIcon item = new ItemIcon();
            Serializer serializer = new Serializer();

            // This shouldn't not produce a "state" element
            item.State = ItemIconStates.None;
            serializer.SerializeRaw(item);

            string xml = @"<ItemIcon xmlns=""http://www.opengis.net/kml/2.2"" />";
            Assert.That(serializer.Xml, Is.EqualTo(xml));

            // Try with more than one value
            item.State = ItemIconStates.Open | ItemIconStates.Error;
            serializer.SerializeRaw(item);

            xml = @"<ItemIcon xmlns=""http://www.opengis.net/kml/2.2""><state>open error</state></ItemIcon>";
            Assert.That(serializer.Xml, Is.EqualTo(xml));

            // Try with an invalid value
            item.State = (ItemIconStates)0x80;
            serializer.SerializeRaw(item);

            xml = @"<ItemIcon xmlns=""http://www.opengis.net/kml/2.2""><state /></ItemIcon>";
            Assert.That(serializer.Xml, Is.EqualTo(xml));
        }
Exemple #2
0
        public void TestWalkCustomElements()
        {
            const int Count = 10;
            CoordinateCollection coordinates = new CoordinateCollection();
            for (int i = 0; i < Count; ++i)
            {
                coordinates.Add(new Vector());
            }
            Assert.That(ElementWalker.Walk(coordinates).Count(), Is.EqualTo(1));

            // This class uses a private class deriving from ICustomElement as a child
            // Make sure it's not included.
            ItemIcon icon = new ItemIcon();
            icon.State = ItemIconStates.Open | ItemIconStates.Error;
            Assert.That(ElementWalker.Walk(icon).Count(), Is.EqualTo(1));
        }
Exemple #3
0
 /// <summary>
 /// Adds the specified <see cref="ItemIcon"/> to this instance.
 /// </summary>
 /// <param name="icon">The <c>ItemIcon</c> to add to this instance.</param>
 /// <exception cref="System.ArgumentNullException">icon is null.</exception>
 /// <exception cref="System.InvalidOperationException">
 /// icon belongs to another <see cref="Element"/>.
 /// </exception>
 public void AddItemIcon(ItemIcon icon)
 {
     this.AddAsChild(this.icons, icon);
 }
Exemple #4
0
 /// <summary>
 /// Adds the specified <see cref="ItemIcon"/> to this instance.
 /// </summary>
 /// <param name="icon">The <c>ItemIcon</c> to add to this instance.</param>
 /// <exception cref="System.ArgumentNullException">icon is null.</exception>
 /// <exception cref="System.InvalidOperationException">
 /// icon belongs to another <see cref="Element"/>.
 /// </exception>
 public void AddItemIcon(ItemIcon icon)
 {
     this.AddChild(icon);
 }
 /// <summary>
 /// Adds the specified <see cref="ItemIcon"/> to this instance.
 /// </summary>
 /// <param name="icon">The <c>ItemIcon</c> to add to this instance.</param>
 /// <exception cref="System.ArgumentNullException">icon is null.</exception>
 /// <exception cref="System.InvalidOperationException">
 /// icon belongs to another <see cref="Element"/>.
 /// </exception>
 public void AddItemIcon(ItemIcon icon)
 {
     this.AddChild(icon);
 }