Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Twitter.Tests/Publicador_tests.cs @ 158:734d3f0853bf
Manejando configuración de los publicadores con una sección propia en los .config
Agregando la opción de habilitar / deshabilitar un publicador
author | nelopauselli |
---|---|
date | Fri, 05 Aug 2011 16:55:18 -0300 |
parents | e6e6bfb1da9e |
children | 2d02adb79322 |
comparison
equal
deleted
inserted
replaced
157:f17252543cbf | 158:734d3f0853bf |
---|---|
2 using AltNetHispano.Agendas.Domain; | 2 using AltNetHispano.Agendas.Domain; |
3 using AltNetHispano.Agendas.Tests; | 3 using AltNetHispano.Agendas.Tests; |
4 using AltNetHispano.Agendas.Twitter; | 4 using AltNetHispano.Agendas.Twitter; |
5 using Moq; | 5 using Moq; |
6 using NUnit.Framework; | 6 using NUnit.Framework; |
7 using Twitterizer; | |
8 | 7 |
9 namespace Agendas.Twitter.Tests | 8 namespace Agendas.Twitter.Tests |
10 { | 9 { |
11 [TestFixture] | 10 [TestFixture] |
12 public class Publicador_tests : TestBase | 11 public class Publicador_tests : TestBase |
13 { | 12 { |
14 [Test] | 13 [Test] |
15 public void Proponer_evento() | 14 public void Proponer_evento() |
16 { | 15 { |
17 var adapter = new Mock<ITwitterAdapter>(); | 16 var adapter = new Mock<ITwitterAdapter>(); |
17 | |
18 string message; | |
18 string twitt = null; | 19 string twitt = null; |
19 | 20 adapter.Setup(a => a.Update(It.IsAny<string>(), out message)).Returns(true).Callback<string, string>((status, m) => twitt = status); |
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 | 21 |
30 var publicador = new TwitterPublicador(adapter.Object); | 22 var publicador = new TwitterPublicador(adapter.Object); |
31 | 23 |
32 var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository, DefaultPatrocinadorRepository); | 24 var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository, DefaultPatrocinadorRepository); |
33 | 25 |
34 agenda.Proponer("Identity Providers", null, null, TipoEvento.GrupoEstudio); | 26 agenda.Proponer("Identity Providers", null, null, TipoEvento.GrupoEstudio); |
35 | 27 |
36 adapter.Verify(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>()), Times.Once()); | 28 adapter.Verify(a => a.Update(It.IsAny<string>(), out message), Times.Once()); |
37 | 29 |
38 Assert.That(twitt, Is.StringContaining("GrupoEstudio")); | 30 Assert.That(twitt, Is.StringContaining("GrupoEstudio")); |
39 } | 31 } |
40 | 32 |
41 [Test] | 33 [Test] |
42 public void Proponer_y_agendar_evento() | 34 public void Proponer_y_agendar_evento() |
43 { | 35 { |
44 var adapter = new Mock<ITwitterAdapter>(); | 36 var adapter = new Mock<ITwitterAdapter>(); |
37 | |
38 string message; | |
45 string twitt = null; | 39 string twitt = null; |
46 | 40 adapter.Setup(a => a.Update(It.IsAny<string>(), out message)).Returns(true).Callback<string, string>((status, m) => twitt = status); |
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 | 41 |
57 var publicador = new TwitterPublicador(adapter.Object); | 42 var publicador = new TwitterPublicador(adapter.Object); |
58 | 43 |
59 var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository, DefaultPatrocinadorRepository); | 44 var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository, DefaultPatrocinadorRepository); |
60 agenda.Proponer("Identity Providers", null, null, TipoEvento.GrupoEstudio); | 45 agenda.Proponer("Identity Providers", null, null, TipoEvento.GrupoEstudio); |
61 | 46 |
62 adapter.Verify(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>()), Times.Once()); | 47 adapter.Verify(a => a.Update(It.IsAny<string>(), out message), Times.Once()); |
63 | 48 |
64 agenda.Agendar("Identity Providers", TestsHelper.GetOrCreatePonente("Nelo Pauselli"), DateTime.Today.AddDays(7), null, TipoEvento.GrupoEstudio); | 49 agenda.Agendar("Identity Providers", TestsHelper.GetOrCreatePonente("Nelo Pauselli"), DateTime.Today.AddDays(7), null, TipoEvento.GrupoEstudio); |
65 | 50 |
66 adapter.Verify(a => a.UpdateStatus(It.IsAny<OAuthTokens>(), It.IsAny<string>()), Times.Exactly(2)); | 51 adapter.Verify(a => a.Update(It.IsAny<string>(), out message), Times.Exactly(2)); |
67 | 52 |
68 Assert.That(twitt, Is.StringContaining("@nelopauselli")); | 53 Assert.That(twitt, Is.StringContaining("@nelopauselli")); |
69 | 54 |
70 } | 55 } |
71 } | 56 } |