comparison Agendas/trunk/src/Agendas.Tests/Blog/PublicadorTests.cs @ 99:3027c64344bd

agregado de llamadas a web service para crear posts en el blog de la comunidad agregado de tests sobre el publicador de blogs agregado de tests sobre el adapter del web service
author jorge.rowies
date Sat, 04 Jun 2011 22:33:05 -0300
parents
children cc91817a4206
comparison
equal deleted inserted replaced
98:4895116b8232 99:3027c64344bd
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using Agendas.Blog;
6 using Agendas.Blog.Impl;
7 using AltNetHispano.Agendas.Domain;
8 using Moq;
9 using NUnit.Framework;
10
11 namespace AltNetHispano.Agendas.Tests.Blog
12 {
13 [TestFixture]
14 public class PublicadorTests
15 {
16 [SetUp]
17 public void SetearUsuario()
18 {
19 var seguridad = new Mock<ISeguridad>();
20 seguridad.Setup(s => s.GetUserName()).Returns("neluz");
21 IdentityContext.Current = seguridad.Object;
22 }
23
24 [Test]
25 public void El_publicador_debe_disparar_los_writers_segun_la_accion_de_cada_track()
26 {
27 var eventoAgendar = Evento.Agendar(null, null, DateTime.MinValue, null);
28 var eventoPublicar = Evento.Agendar(null, null, DateTime.MinValue, null);
29
30 var agendarPostWriter = new Mock<IPostWriter>();
31 agendarPostWriter.Setup(writer => writer.WritePost(eventoAgendar));
32
33 var publicarPostWriter = new Mock<IPostWriter>();
34 publicarPostWriter.Setup(writer => writer.WritePost(eventoPublicar));
35
36 var factory = new Mock<IPostWriterFactory>();
37 factory.Setup(f => f.GetPostWriter(Accion.Agendar)).Returns(agendarPostWriter.Object);
38 factory.Setup(f => f.GetPostWriter(Accion.Publicar)).Returns(publicarPostWriter.Object);
39
40 var publicador = new BlogPublicador(factory.Object);
41 publicador.Publicar(new List<Track>
42 {
43 new Track(eventoAgendar, Accion.Agendar),
44 new Track(eventoPublicar, Accion.Publicar)
45 });
46
47 factory.Verify(f => f.GetPostWriter(Accion.Agendar), Times.Once());
48 factory.Verify(f => f.GetPostWriter(Accion.Publicar), Times.Once());
49
50 agendarPostWriter.Verify(pw => pw.WritePost(eventoAgendar), Times.Once());
51 publicarPostWriter.Verify(pw => pw.WritePost(eventoPublicar), Times.Once());
52 }
53 }
54 }