view Agendas/trunk/src/Agendas.Google.Test/GUrlShortenerTest.cs @ 259:e6c041d8e1bf

Ticket #193.1: Al guardar (nuevo/modificar) una persona, que la cuenta de twitter no comience con @
author juanjose.montesdeocaarbos
date Thu, 20 Oct 2011 08:16:55 -0300
parents 806fd94727ce
children
line wrap: on
line source

using System;
using System.Net;
using AltNetHispano.Agendas.Google;
using NUnit.Framework;

namespace Agendas.Google.Test
{
	[TestFixture]
	public class GUrlShortenerTest
	{
		[Test]
		public void Obtener_url_corta()
		{
			var gUrlShortener = new GUrlShortenerAdapter();

			var shortUrl = gUrlShortener.GetShortUrl("http://www.twitter.com");

			Console.WriteLine(shortUrl);

			Assert.AreEqual("http://goo.gl/CbHS", shortUrl);
		}

		[Test]
		public void Acceder_a_url_corta()
		{
			var gUrlShortener = new GUrlShortenerAdapter();

			var shortUrl = gUrlShortener.GetShortUrl("http://altnethispano.org");

			Console.WriteLine(shortUrl);

			var request = WebRequest.Create(shortUrl);
			var response = request.GetResponse() as HttpWebResponse;

			Assert.IsNotNull(response);
			Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);

			Assert.AreEqual(new Uri("http://altnethispano.org/Inicio.aspx"), response.ResponseUri);

		}

        [Test]
        public void Parametros_Invalidos_En_GetShortUrl()
        {
            var gUrlShortener = new GUrlShortenerAdapter();

            Assert.Throws<ArgumentException>(() => gUrlShortener.GetShortUrl(string.Empty));
            Assert.Throws<ArgumentNullException>(() => gUrlShortener.GetShortUrl(null));
        }
    }
}