public void AddRange_should_add_multiple_items_nominal()
        {
            var list = new DomStringTokenList();

            Assert.True(list.AddRange("d", "e"));
            Assert.Equal("d e", list.ToString());
        }
        public void AddRange_should_ignore_empty_or_null()
        {
            var list = new DomStringTokenList();

            Assert.False(list.AddRange(string.Empty));
            Assert.False(list.AddRange(null, null));
        }
        public void AddRange_should_return_true_given_new_items()
        {
            var list = new DomStringTokenList();

            list.AddRange("a", "b", "c");
            Assert.True(list.AddRange("a", "b", "c", "d"));
            Assert.False(list.AddRange("c"));
        }
        public void Contains_and_add_are_case_sensitive()
        {
            DomStringTokenList list = new DomStringTokenList();

            list.Add("nom");

            Assert.False(list.Contains("NOM"));
        }
        public void Clone_produces_shallow_copy()
        {
            IDomValue list = new DomStringTokenList {
                "a", "b", "c"
            };

            Assert.NotSame(list, list.Clone());
            Assert.Equal(list, list.Clone());
        }
        public void AppendValue_will_add_the_item_as_text()
        {
            var list = new DomStringTokenList {
                "a"
            };

            ((IDomValue)list).AppendValue(500);
            Assert.Equal(new [] { "a", "500" }, list);
        }
        public void Toggle_implies_Contains()
        {
            DomStringTokenList list = new DomStringTokenList();

            list.Toggle("nom");
            Assert.True(list.Contains("nom"));

            list.Toggle("nom");
            Assert.False(list.Contains("nom"));
            Assert.Equal("", list.ToString());
        }
Esempio n. 8
0
        public void Attribute_set_dom_value_setter()
        {
            DomDocument doc       = new DomDocument();
            var         html      = doc.AppendElement("html");
            var         classList = new DomStringTokenList();

            html.Attribute("class", classList);
            html.Attribute("class", "heat up");
            Assert.Contains("heat", classList);
            Assert.Contains("up", classList);
        }
        public void Add_nominal()
        {
            DomStringTokenList list = new DomStringTokenList();

            list.Add("nom");

            Assert.True(list.Contains("nom"));
            Assert.Equal(1, list.Count);
            Assert.Equal("nom", list.ToString());
            Assert.Equal(new [] { "nom" }, list.ToArray());
        }
        public void AppendValue_will_add_range_of_items()
        {
            var list = new DomStringTokenList {
                "a"
            };
            var other = new DomStringTokenList {
                "a", "b"
            };

            ((IDomValue)list).AppendValue(other);
            Assert.Equal(new [] { "a", "b" }, list);
        }
        public void Parse_nominal()
        {
            DomStringTokenList list = DomStringTokenList.Parse(" red \t\tgreen blue \t\r\n");

            Assert.True(list.Contains("red"));
            Assert.True(list.Contains("green"));
            Assert.True(list.Contains("blue"));

            Assert.Equal("red", list[0]);
            Assert.Equal("green", list[1]);
            Assert.Equal("blue", list[2]);
            Assert.Equal("red green blue", list.ToString());
        }
Esempio n. 12
0
        public void Attribute_set_dom_value_getter()
        {
            DomDocument doc       = new DomDocument();
            var         html      = doc.AppendElement("html");
            var         classList = new DomStringTokenList();

            html.Attribute("class", classList);

            Assert.Equal(string.Empty, html.Attribute("class"));
            classList.Add("cool");
            classList.Add("down");
            Assert.Equal("cool down", html.Attribute("class"));
        }
        public void Contains_Add_set_cache_implementation()
        {
            var list = DomStringTokenList.Parse("1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18");

            Assert.Equal(18, list.Count);
            Assert.Equal("1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18", list.ToString());
            for (int i = 1; i <= 18; i++)
            {
                Assert.True(list.Contains(i.ToString()));
            }

            Assert.False(list.Add("2"));
            Assert.True(list.Remove("2"));
            Assert.False(list.Contains("2"));
            Assert.True(list.Add("19"));
        }
        public void Toggle_explicit_equivalence()
        {
            DomStringTokenList list = new DomStringTokenList();

            list.Toggle(false, "nom");
            Assert.False(list.Contains("nom"));

            list.Toggle(true, "nom");
            Assert.True(list.Contains("nom"));

            list.Toggle(true, "nom");
            Assert.True(list.Contains("nom"));

            list.Toggle(false, "nom");
            Assert.False(list.Contains("nom"));
        }
Esempio n. 15
0
        protected override IHxlElementTemplate OnElementRendering()
        {
            object myFeatures = null;

            try {
                myFeatures = ((dynamic)TemplateContext).Features;
            } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException) {
            }

            DomStringTokenList features = ConvertFeatures(myFeatures);

            if (features != null && features.Contains(Feature))
            {
                return(null);
            }

            return(HxlElementTemplate.Skip);
        }
Esempio n. 16
0
        public HxlElementTemplateInfo(string element, DomStringTokenList classList)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (string.IsNullOrEmpty(element))
            {
                throw Failure.EmptyString("element");
            }

            if (classList == null)
            {
                _classList = new DomStringTokenList();
            }
            else
            {
                _classList = classList.IsReadOnly ? classList : classList.Clone();
            }

            // UNDONE _classList.MakeReadOnly();
            _element = element;
        }
Esempio n. 17
0
        static DomStringTokenList ConvertFeatures(object myFeatures)
        {
            if (myFeatures == null)
            {
                return(null);
            }

            var features = myFeatures as DomStringTokenList;

            if (features != null)
            {
                return(features);
            }

            string text = myFeatures as string;

            if (text != null &&
                DomStringTokenList.TryParse(text, out features))
            {
                return(features);
            }

            return(null);
        }
 private InstanceDescriptor CreateInstanceDescriptor(ITypeDescriptorContext context, CultureInfo culture, DomStringTokenList value)
 {
     return new InstanceDescriptor(typeof(DomStringTokenList).GetConstructor(new [] { typeof(string) }),
                                   new object[] { value.ToString() });
 }
Esempio n. 19
0
        public void test_set_dom_value_getter()
        {
            DomDocument doc = new DomDocument();
            var html = doc.AppendElement("html");
            var classList = new DomStringTokenList();
            html.Attribute("class", classList);

            Assert.That(html.Attribute("class"), Is.EqualTo(string.Empty));
            classList.Add("cool");
            classList.Add("down");
            Assert.That(html.Attribute("class"), Is.EqualTo("cool down"));
        }
Esempio n. 20
0
 public void test_set_dom_value_setter()
 {
     DomDocument doc = new DomDocument();
     var html = doc.AppendElement("html");
     var classList = new DomStringTokenList();
     html.Attribute("class", classList);
     html.Attribute("class", "heat up");
     Assert.That(classList, Contains.Item("heat"));
     Assert.That(classList, Contains.Item("up"));
 }
        public void Parse_null_or_empty_string_are_empty(string text)
        {
            DomStringTokenList list = DomStringTokenList.Parse(text);

            Assert.Equal(DomStringTokenList.Empty, list);
        }
 public void test_cannot_contain_ws_in_add()
 {
     DomStringTokenList list = new DomStringTokenList();
     Assert.That(() => list.Add("cannot\tws"), Throws.ArgumentException);
 }
        public void Add_cannot_contain_whitespace_in_tokens()
        {
            DomStringTokenList list = new DomStringTokenList();

            Assert.Throws <ArgumentException>(() => list.Add("cannot\tws"));
        }