Mercurial > altnet-hispano
diff Agendas/trunk/src/Agendas.Twitter.Tests/Publicador_tests.cs @ 111:90ce239cfa6d
Tests sobre el publicador de twitter, cada track se pulica solo una vez
author | Nelo@Kenia.neluz.int |
---|---|
date | Wed, 08 Jun 2011 08:40:04 -0300 |
parents | |
children | 62791999ad01 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Twitter.Tests/Publicador_tests.cs Wed Jun 08 08:40:04 2011 -0300 @@ -0,0 +1,72 @@ +using System; +using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Tests; +using AltNetHispano.Agendas.Twitter; +using Moq; +using NUnit.Framework; +using Twitterizer; + +namespace Agendas.Twitter.Tests +{ + [TestFixture] + public class Publicador_tests : TestBase + { + [Test] + public void Proponer_evento() + { + var adapter = new Mock<ITwitterAdapter>(); + string twitt = null; + + var response = new TwitterResponse<TwitterStatus> + { + Result = + RequestResult.Success + }; + + adapter.Setup(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>())) + .Returns(response) + .Callback<OAuthTokens, string>((tokens, status) => twitt = status); + + var publicador = new TwitterPublicador(adapter.Object); + + var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository); + + agenda.Proponer("Identity Providers", null, null, TipoEvento.GrupoEstudio); + + adapter.Verify(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>()), Times.Once()); + + Assert.That(twitt, Is.StringContaining("GrupoEstudio")); + } + + [Test] + public void Proponer_y_agendar_evento() + { + var adapter = new Mock<ITwitterAdapter>(); + string twitt = null; + + var response = new TwitterResponse<TwitterStatus> + { + Result = + RequestResult.Success + }; + + adapter.Setup(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>())) + .Returns(response) + .Callback<OAuthTokens, string>((tokens, status) => twitt = status); + + var publicador = new TwitterPublicador(adapter.Object); + + var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository); + agenda.Proponer("Identity Providers", null, null, TipoEvento.GrupoEstudio); + + adapter.Verify(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>()), Times.Once()); + + agenda.Agendar("Identity Providers", "Nelo Pauselli", DateTime.Today.AddDays(7), null, TipoEvento.GrupoEstudio); + + adapter.Verify(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>()), Times.Exactly(2)); + + Assert.That(twitt, Is.StringContaining("@nelopauselli")); + + } + } +} \ No newline at end of file