comparison Agendas/trunk/src/Agendas.Tests/Blog/PublicadorTests.cs @ 109:6bd9be78caa0

Merge
author Nelo@Kenia.neluz.int
date Tue, 07 Jun 2011 23:21:07 -0300
parents 1d820f17fc75
children
comparison
equal deleted inserted replaced
108:786a90e26c9b 109:6bd9be78caa0
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 AltNetHispano.Agendas.Repositories.Memory;
9 using Moq;
10 using NUnit.Framework;
11
12 namespace AltNetHispano.Agendas.Tests.Blog
13 {
14 [TestFixture]
15 public class PublicadorTests
16 {
17 [SetUp]
18 public void SetearUsuario()
19 {
20 var seguridad = new Mock<ISeguridad>();
21 seguridad.Setup(s => s.GetUserName()).Returns("neluz");
22 IdentityContext.Init(seguridad.Object, new PersonaRepository());
23 }
24
25 [Test]
26 public void El_publicador_debe_disparar_los_writers_segun_la_accion_de_cada_track()
27 {
28 //var eventoAgendar = Evento.Agendar(null, null, DateTime.MinValue, null);
29 //var eventoPublicar = Evento.Agendar(null, null, DateTime.MinValue, null);
30
31 var trackAgendar = new Track(null, Accion.Agendar);
32 var trackPublicar = new Track(null, Accion.Publicar);
33
34 var agendarPostWriter = new Mock<IPostWriter>();
35 agendarPostWriter.Setup(writer => writer.WritePost(trackAgendar));
36
37 var publicarPostWriter = new Mock<IPostWriter>();
38 publicarPostWriter.Setup(writer => writer.WritePost(trackPublicar));
39
40 var factory = new Mock<IPostWriterFactory>();
41 factory.Setup(f => f.GetPostWriter(Accion.Agendar)).Returns(agendarPostWriter.Object);
42 factory.Setup(f => f.GetPostWriter(Accion.Publicar)).Returns(publicarPostWriter.Object);
43
44 var publicador = new BlogPublicador(factory.Object);
45 publicador.Publicar(new List<Track>
46 {
47 trackAgendar,
48 trackPublicar
49 });
50
51 factory.Verify(f => f.GetPostWriter(Accion.Agendar), Times.Once());
52 factory.Verify(f => f.GetPostWriter(Accion.Publicar), Times.Once());
53
54 agendarPostWriter.Verify(pw => pw.WritePost(trackAgendar), Times.Once());
55 publicarPostWriter.Verify(pw => pw.WritePost(trackPublicar), Times.Once());
56 }
57 }
58 }