# HG changeset patch # User juanjose.montesdeocaarbos # Date 1317639054 10800 # Node ID 806fd94727ce946803a47f80b056fd38a4207518 # Parent 4d05b5883eacb2a98cb67a6226d554511e5f8fb5 Validación de parámetros en GUrlShortener diff -r 4d05b5883eac -r 806fd94727ce Agendas/trunk/src/Agendas.Google.Test/GUrlShortenerTest.cs --- a/Agendas/trunk/src/Agendas.Google.Test/GUrlShortenerTest.cs Mon Sep 26 09:29:59 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Google.Test/GUrlShortenerTest.cs Mon Oct 03 07:50:54 2011 -0300 @@ -38,5 +38,14 @@ Assert.AreEqual(new Uri("http://altnethispano.org/Inicio.aspx"), response.ResponseUri); } - } + + [Test] + public void Parametros_Invalidos_En_GetShortUrl() + { + var gUrlShortener = new GUrlShortenerAdapter(); + + Assert.Throws(() => gUrlShortener.GetShortUrl(string.Empty)); + Assert.Throws(() => gUrlShortener.GetShortUrl(null)); + } + } } diff -r 4d05b5883eac -r 806fd94727ce Agendas/trunk/src/Agendas.Google/GUrlShortenerAdapter.cs --- a/Agendas/trunk/src/Agendas.Google/GUrlShortenerAdapter.cs Mon Sep 26 09:29:59 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Google/GUrlShortenerAdapter.cs Mon Oct 03 07:50:54 2011 -0300 @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using System.Net; using AltNetHispano.Agendas.Configurations; @@ -15,6 +16,11 @@ public string GetShortUrl(string url) { + if (url == null) + throw new ArgumentNullException("url"); + else if (string.IsNullOrWhiteSpace(url)) + throw new ArgumentException(); + WebRequest request = WebRequest.Create(_config.UrlAPI); request.Method = WebRequestMethods.Http.Post; request.ContentType = "application/json";