GravatarImage() public static method

Returns a Globally Recognised Avatar as an <img /> - http://gravatar.com
public static GravatarImage ( this htmlHelper, string emailAddress, int size = 80, DefaultImage defaultImage = DefaultImage.Default, string defaultImageUrl = "", bool forceDefaultImage = false, Rating, rating = Rating.G, bool forceSecureRequest = false ) : IHtmlContent
htmlHelper this
emailAddress string Email Address for the Gravatar
size int Size in pixels (default: 80)
defaultImage DefaultImage Default image if user hasn't created a Gravatar
defaultImageUrl string URL to a custom default image (e.g: 'Url.Content("~/images/no-grvatar.png")' )
forceDefaultImage bool Prefer the default image over the users own Gravatar
rating Rating, Gravatar content rating (note that Gravatars are self-rated)
forceSecureRequest bool Always do secure (https) requests
return IHtmlContent
        public void Expect_ToForceDefaultImg_WhenGIvenParam()
        {
            // Arrange
            var mockViewContext       = new Mock <ViewContext>();
            var mockViewDataContainer = new Mock <IViewDataContainer>();
            var htmlHelper            = new HtmlHelper(mockViewContext.Object, mockViewDataContainer.Object);

            // Act
            var result = GravatarHtmlHelper.GravatarImage(htmlHelper, string.Empty, forceDefaultImage: true);

            // Assert
            Assert.IsInstanceOf <HtmlString>(result);
            StringAssert.Contains("f=y", result.ToString());
        }
        public void Expect_ToSwitchToUnsecure_WhenGivenParam()
        {
            // Arrange
            var mockViewContext       = new Mock <ViewContext>();
            var mockViewDataContainer = new Mock <IViewDataContainer>();
            var htmlHelper            = new HtmlHelper(mockViewContext.Object, mockViewDataContainer.Object);

            // Act
            var result = GravatarHtmlHelper.GravatarImage(htmlHelper, string.Empty, forceSecureRequest: false);

            // Assert
            Assert.IsInstanceOf <HtmlString>(result);
            StringAssert.DoesNotContain("https", result.ToString());
        }
        public void Expect_ToReturnCorrectImageTagWithCustomImage()
        {
            // Arrange
            var email     = "*****@*****.**";
            var emailHash = "b642b4217b34b1e8d3bd915fc65c4452";

            var mockViewContext       = new Mock <ViewContext>();
            var mockViewDataContainer = new Mock <IViewDataContainer>();
            var htmlHelper            = new HtmlHelper(mockViewContext.Object, mockViewDataContainer.Object);

            // Act
            var result = GravatarHtmlHelper.GravatarImage(htmlHelper,
                                                          email,
                                                          defaultImageUrl: "test.jpg");

            // Assert
            Assert.IsInstanceOf <HtmlString>(result);
            StringAssert.Contains(emailHash, result.ToString());
            StringAssert.Contains("d=test.jpg", result.ToString());
        }