Exemplo n.º 1
0
        public void SelectOptionsRemoveOptionShouldWork()
        {
            var document = String.Empty.ToHtmlDocument();
            var div      = document.CreateElement <IHtmlDivElement>();
            var select   = document.CreateElement <IHtmlSelectElement>();

            div.AppendChild(select);
            Assert.AreEqual(div, select.Parent);
            var options = new IHtmlOptionElement[3];

            for (int i = 0; i < options.Length; i++)
            {
                options[i]             = document.CreateElement <IHtmlOptionElement>();
                options[i].TextContent = i.ToString();
                select.AppendChild(options[i]);
            }

            select.Options.Remove(-1);
            CollectionAssert.AreEqual(options, select.Options);

            select.Options.Remove(3);
            CollectionAssert.AreEqual(options, select.Options);

            select.Options.Remove(0);
            CollectionAssert.AreEqual(new[] { options[1], options[2] }, select.Options);
        }
Exemplo n.º 2
0
        public void SetOptionAt(Int32 index, IHtmlOptionElement value)
        {
            var child = GetOptionAt(index);

            if (child != null)
            {
                _parent.ReplaceChild(value, child);
            }
            else
            {
                _parent.AppendChild(value);
            }
        }
Exemplo n.º 3
0
        public async Task <ISutApp> SelectOnElement(IHtmlOptionElement selectable)
        {
            if (selectable == null)
            {
                throw new ArgumentNullException(nameof(selectable));
            }

            var type = selectable.GetType();

            if (selectable.Value == null)
            {
                throw new NotImplementedException($"selectable {type.FullName} is not supported.");
            }


            return(this as TApp);
        }
Exemplo n.º 4
0
 public void Add(IHtmlOptionElement element, IHtmlElement before = null)
 {
     _parent.InsertBefore(element, before);
 }
Exemplo n.º 5
0
 public void AddOption(IHtmlOptionElement element, IHtmlElement before = null)
 {
     Options.Add(element, before);
 }
Exemplo n.º 6
0
 public void Add(IHtmlOptionElement element, IHtmlElement before = null)
 {
     _parent.InsertBefore(element, before);
 }
Exemplo n.º 7
0
        public void SetOptionAt(Int32 index, IHtmlOptionElement value)
        {
            var child = GetOptionAt(index);

            if (child != null)
            {
                _parent.ReplaceChild(value, child);
            }
            else
            {
                _parent.AppendChild(value);
            }
        }
Exemplo n.º 8
0
 public void SetOptionAt(Int32 index, IHtmlOptionElement value)
 {
     _parent.ReplaceChild(value, GetOptionAt(index));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Adds the element to the options collection.
 /// </summary>
 /// <param name="element">The option element to add.</param>
 /// <param name="before">The following element.</param>
 public void AddOption(IHtmlOptionElement element, IHtmlElement before = null)
 {
     Options.Add(element, before);
 }
Exemplo n.º 10
0
        public void SelectOptionsRemoveOptionShouldWork()
        {
            var document = String.Empty.ToHtmlDocument();
            var div = document.CreateElement<IHtmlDivElement>();
            var select = document.CreateElement<IHtmlSelectElement>();
            div.AppendChild(select);
            Assert.AreEqual(div, select.Parent);
            var options = new IHtmlOptionElement[3];

            for (int i = 0; i < options.Length; i++)
            {
                options[i] = document.CreateElement<IHtmlOptionElement>();
                options[i].TextContent = i.ToString();
                select.AppendChild(options[i]);
            }

            select.Options.Remove(-1);
            CollectionAssert.AreEqual(options, select.Options);

            select.Options.Remove(3);
            CollectionAssert.AreEqual(options, select.Options);

            select.Options.Remove(0);
            CollectionAssert.AreEqual(new[] { options[1], options[2] }, select.Options);
        }