view Agendas/trunk/src/Agendas.Twitter.Tests/Publicador_tests.cs @ 150:19bab30521da

Pasando DateTime a un EditorTemplates
author Nelo@Guinea.neluz.int
date Tue, 02 Aug 2011 23:24:19 -0300
parents e6e6bfb1da9e
children 734d3f0853bf
line wrap: on
line source

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, DefaultPatrocinadorRepository);

			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, DefaultPatrocinadorRepository);
			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", TestsHelper.GetOrCreatePonente("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"));

		}
	}
}