public void FilterToDictionary_ReturnsDictionaryForDictionaryArgument() { var dict1 = new Dictionary<string, object> { { "val1", 1 }, { "val2", "two" }, { "val3", null } }; var dict2 = new HtmlAttributeTypeFilter().FilterToDictionary(dict1); CollectionAssert.AreEqual(dict1, dict2); }
public void FilterToDictionary_ReturnsDictionaryForDictionaryArgument() { var dict1 = new Dictionary <string, object> { { "val1", 1 }, { "val2", "two" }, { "val3", null } }; var dict2 = new HtmlAttributeTypeFilter().FilterToDictionary(dict1); CollectionAssert.AreEqual(dict1, dict2); }
public void FilterToDictionary_ReturnsDictionaryForObject() { var obj = new { value1 = 100, value2 = "2", value3 = default(object) }; var expected = new Dictionary<string, object> { { "value1", 100 }, { "value2", "2" }, { "value3", null } }; var actual = new HtmlAttributeTypeFilter().FilterToDictionary(obj); CollectionAssert.AreEqual(expected, actual); }
public void FilterToDictionary_ReturnsDictionaryForObject() { var obj = new { value1 = 100, value2 = "2", value3 = default(object) }; var expected = new Dictionary <string, object> { { "value1", 100 }, { "value2", "2" }, { "value3", null } }; var actual = new HtmlAttributeTypeFilter().FilterToDictionary(obj); CollectionAssert.AreEqual(expected, actual); }
/// <summary> /// Gets a link tag of the Gravatar profile for the specified <paramref name="emailAddress"/>. /// </summary> /// <param name="htmlHelper">The HtmlHelper object that does the rendering.</param> /// <param name="emailAddress">The email address whose Gravatar profile link should be rendered.</param> /// <param name="linkText">The link text to display.</param> /// <param name="useHttps"><c>true</c> to use the HTTPS Gravatar URL. Otherwise, <c>false</c>.</param> /// <param name="htmlAttributes">Additional attributes to include in the rendered tag.</param> /// <returns>An HTML string of the rendered link tag.</returns> public static MvcHtmlString GravatarProfileLink( this HtmlHelper htmlHelper, string emailAddress, string linkText, bool?useHttps = null, object htmlAttributes = null ) { return(MvcHtmlString.Create( GravatarProfile.RenderLink( emailAddress, linkText, useHttps, HtmlAttributeTypeFilter.FilterToDictionary(htmlAttributes) ) )); }
/// <summary> /// Gets an <c>img</c> tag of the Gravatar for the supplied email address and parameters. /// </summary> /// <param name="htmlHelper">The HtmlHelper object that does the rendering.</param> /// <param name="emailAddress">The email address whose Gravatar should be rendered.</param> /// <param name="size">The size of the rendered Gravatar.</param> /// <param name="rating">The maximum Gravatar rating to allow for rendered Gravatars.</param> /// <param name="default">The default image to display if no Gravatar exists for the specified <paramref name="emailAddress"/>.</param> /// <param name="forceDefault"><c>true</c> to always display the default image. Otherwise, <c>false</c>.</param> /// <param name="useHttps"><c>true</c> to use the HTTPS Gravatar URL. Otherwise, <c>false</c>.</param> /// <param name="htmlAttributes">Additional attributes to include in the rendered <c>img</c> tag.</param> /// <returns>An HTML string of the rendered <c>img</c> tag.</returns> public static MvcHtmlString Gravatar( this HtmlHelper htmlHelper, string emailAddress, int?size = null, GravatarRating?rating = null, string @default = null, bool?forceDefault = null, bool?useHttps = null, object htmlAttributes = null ) { return(MvcHtmlString.Create( NGravatar.Gravatar.DefaultInstance.Render( emailAddress, size, rating, @default, forceDefault, useHttps, HtmlAttributeTypeFilter.FilterToDictionary(htmlAttributes) ) )); }