comparison 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
comparison
equal deleted inserted replaced
110:a456eb519e23 111:90ce239cfa6d
1 using System;
2 using AltNetHispano.Agendas.Domain;
3 using AltNetHispano.Agendas.Tests;
4 using AltNetHispano.Agendas.Twitter;
5 using Moq;
6 using NUnit.Framework;
7 using Twitterizer;
8
9 namespace Agendas.Twitter.Tests
10 {
11 [TestFixture]
12 public class Publicador_tests : TestBase
13 {
14 [Test]
15 public void Proponer_evento()
16 {
17 var adapter = new Mock<ITwitterAdapter>();
18 string twitt = null;
19
20 var response = new TwitterResponse<TwitterStatus>
21 {
22 Result =
23 RequestResult.Success
24 };
25
26 adapter.Setup(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>()))
27 .Returns(response)
28 .Callback<OAuthTokens, string>((tokens, status) => twitt = status);
29
30 var publicador = new TwitterPublicador(adapter.Object);
31
32 var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository);
33
34 agenda.Proponer("Identity Providers", null, null, TipoEvento.GrupoEstudio);
35
36 adapter.Verify(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>()), Times.Once());
37
38 Assert.That(twitt, Is.StringContaining("GrupoEstudio"));
39 }
40
41 [Test]
42 public void Proponer_y_agendar_evento()
43 {
44 var adapter = new Mock<ITwitterAdapter>();
45 string twitt = null;
46
47 var response = new TwitterResponse<TwitterStatus>
48 {
49 Result =
50 RequestResult.Success
51 };
52
53 adapter.Setup(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>()))
54 .Returns(response)
55 .Callback<OAuthTokens, string>((tokens, status) => twitt = status);
56
57 var publicador = new TwitterPublicador(adapter.Object);
58
59 var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository);
60 agenda.Proponer("Identity Providers", null, null, TipoEvento.GrupoEstudio);
61
62 adapter.Verify(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>()), Times.Once());
63
64 agenda.Agendar("Identity Providers", "Nelo Pauselli", DateTime.Today.AddDays(7), null, TipoEvento.GrupoEstudio);
65
66 adapter.Verify(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>()), Times.Exactly(2));
67
68 Assert.That(twitt, Is.StringContaining("@nelopauselli"));
69
70 }
71 }
72 }