using System; using AutoMapper; using NUnit.Framework; [TestFixture] public class When_resolving_the_gravatar_url_for_an_email_address { IValueResolver resolver = new GravatarUrlResolver(); [Test] [ExpectedException(typeof(ArgumentNullException))] public void Should_throw_exception_if_resolution_source_is_null() { resolver.Resolve(null); } [Test] public void Should_return_gravatar_url_with_md5_hash_of_email_address() { Uri url = (Uri)resolver.Resolve(new ResolutionResult("iHaveAn@email.com")).Value; Assert.AreEqual("http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802", url.AbsoluteUri); } [TestFixture] public class and_the_email_address_is_null_or_empty : When_resolving_the_gravatar_url_for_an_email_address { [Test] public void Should_return_default_url([Values(null, "")]string email) { Uri url = (Uri)resolver.Resolve(new ResolutionResult(email)).Value; Assert.AreEqual("http://www.gravatar.com/avatar/?d=identicon", url.AbsoluteUri); } } }