Exemplo n.º 1
0
        public void AddObject_WithUnderscorePropertyName_ThenDashPropertyName()
        {
            var target = new HtmlAttributeDictionary();

            target.Add(new { data_value = "test" });

            target.Where(k => k.Key == "data-value").Select(k => k.Key).FirstOrDefault().ShouldEqual("data-value");
        }
Exemplo n.º 2
0
        public void AddNameValuePair_WithUnderscorePropertyName_ThenRemainsUnderscoreName()
        {
            var target = new HtmlAttributeDictionary();

            target.Add("data_value", "test");

            target.Where(k => k.Key == "data_value").Select(k => k.Key).FirstOrDefault().ShouldEqual("data_value");
        }
Exemplo n.º 3
0
        public void WhenGetAttributeWithNullName_ThenThrowException()
        {
            var target = new HtmlAttributeDictionary();

            Assert.Throws <ArgumentException>(
                () => { var _ = target[null]; }
                );
        }
Exemplo n.º 4
0
        public void WithUpperPropertyName_ThenLowerName()
        {
            var target = new HtmlAttributeDictionary();

            target.Add(new { ASYNC = "async" });

            target.Where(k => k.Key == "async").Select(k => k.Key).FirstOrDefault().ShouldEqual("async");
        }
Exemplo n.º 5
0
        public void WithObjectWithTwoProperties_ThenDictionaryTwoKeyValuePairs()
        {
            var target = new HtmlAttributeDictionary().Add(new { @class = "TestClass", async = "async" });

            target.Count.ShouldEqual(2);
            target["class"].ShouldEqual("TestClass");
            target["async"].ShouldEqual("async");
        }
Exemplo n.º 6
0
        public void WhenRemoveAttributeWithEmptyName_ThenThrowException()
        {
            var target = new HtmlAttributeDictionary();

            Assert.Throws <ArgumentException>(
                () => target.Remove("")
                );
        }
Exemplo n.º 7
0
        public void CanSetAndGetValueByName()
        {
            var target = new HtmlAttributeDictionary();

            target["test"] = "value";

            target["test"].ShouldEqual("value");
        }
Exemplo n.º 8
0
        public void WhenAttributes_ThenContainsValidString()
        {
            var dictionary = new HtmlAttributeDictionary().Add(new { @class = "test", foo = "\"bar\"" });

            dictionary.Add("async");

            dictionary.CombinedAttributes.ShouldEqual(" class=\"test\" foo=\"&quot;bar&quot;\" async");
        }
Exemplo n.º 9
0
        public void WhenAttributeNameIsEmpty_ThenContainsAttributesThrowsException()
        {
            var target = new HtmlAttributeDictionary();

            Assert.Throws <ArgumentException>(
                () => target.ContainsAttribute("")
                );
        }
Exemplo n.º 10
0
        public void GivenAttributeInDictionary_ThenContainsAttributeIsTrue()
        {
            var target = new HtmlAttributeDictionary {
                "example"
            };

            target.ContainsAttribute("example").ShouldBeTrue();
        }
Exemplo n.º 11
0
        public void WithEmptyName_ThenArgumentException()
        {
            var target = new HtmlAttributeDictionary();

            Assert.Throws <ArgumentException>(
                () => target.Add(string.Empty, "async")
                );
        }
Exemplo n.º 12
0
        public void GivenDictionaryWithAttribute_WhenRemoveAttributeWithDifferentName_ThenReturnFalse()
        {
            var target = new HtmlAttributeDictionary {
                "test"
            };
            var removed = target.Remove("something-else");

            removed.ShouldBeFalse();
        }
Exemplo n.º 13
0
        public void GivenDictionaryWithAttribute_WhenRemoveAttributeByName_ThenReturnTrue()
        {
            var target = new HtmlAttributeDictionary {
                "test"
            };
            var removed = target.Remove("test");

            removed.ShouldBeTrue();
        }
Exemplo n.º 14
0
        public void WithDictionaryWithOneEntityAndObjectWithTwoProperties_ThenThreeKeyValuePairs()
        {
            var target = new HtmlAttributeDictionary();

            target.Add("existing", "value");

            target.Add(new { @class = "TestClass", async = "async" });

            target.Count.ShouldEqual(3);
        }
Exemplo n.º 15
0
        public void GivenEmptyDictionary_ThenContainsAttributeIsFalse()
        {
            var target = new HtmlAttributeDictionary();

            target.ContainsAttribute("example").ShouldBeFalse();
        }