public void WithDictionaryWithOneEntityAndObjectWithTwoProperties_ThenThreeKeyValuePairs() { var target = new HtmlAttributeDictionary(); target.Add("existing", "value"); target.Add(new { @class = "TestClass", async = "async" }); target.Count.ShouldEqual(3); }
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"); }
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"); }
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"); }
public void WhenAttributes_ThenContainsValidString() { var dictionary = new HtmlAttributeDictionary().Add(new { @class = "test", foo = "\"bar\"" }); dictionary.Add("async"); dictionary.CombinedAttributes.ShouldEqual(" class=\"test\" foo=\""bar"\" async"); }
public void WithEmptyName_ThenArgumentException() { var target = new HtmlAttributeDictionary(); Assert.Throws <ArgumentException>( () => target.Add(string.Empty, "async") ); }