Mercurial > altnet-hispano
diff Agendas/trunk/src/Agendas.Repositories.Tests/WorkflowTests.cs @ 222:68b09c30b0d2
Separando los test de persistencia en un proyecto aparte
author | nelopauselli |
---|---|
date | Mon, 19 Sep 2011 18:18:17 -0300 |
parents | |
children | 72a96459f910 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/WorkflowTests.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using Agendas.Repositories.Tests.Infraestructure; +using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Domain.Repositories; +using Moq; +using NUnit.Framework; + +namespace Agendas.Repositories.Tests +{ + public abstract class WorkflowTests<T> where T : IInfraestrutureFactory, new() + { + private readonly IPersonaRepository _personaRepository; + private readonly IEventoRepository _eventoRepository; + private readonly Func<IDisposable> _requestEmulator; + + protected WorkflowTests() + { + var infraestrutureFactory = new T(); + + _eventoRepository = infraestrutureFactory.GetEventoRepository(); + _personaRepository = infraestrutureFactory.GetPonenteRepository(); + _requestEmulator = infraestrutureFactory.GetRequestEmulator(); + } + + [SetUp] + public void SetearUsuario() + { + var seguridad = new Mock<ISeguridad>(); + seguridad.Setup(s => s.GetUserName()).Returns("neluz"); + IdentityContext.Init(seguridad.Object, _personaRepository); + } + + [Test] + public void Proponer() + { + var publicador = new Mock<IPublicador>(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Once()); + } + + [Test] + public void Proponer_y_agendar() + { + var publicador = new Mock<IPublicador>(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(2)); + } + [Test] + public void Proponer_agendar_y_cancelar() + { + var publicador = new Mock<IPublicador>(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Cancelar(); + + publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(3)); + } + + [Test] + public void Proponer_agendar_cancelar_y_reagendar() + { + var publicador = new Mock<IPublicador>(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Cancelar(); + + workflow.ReAgendar(); + + publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(4)); + } + + [Test] + public void Proponer_agendar_cancelar_reproponer_agendar_y_confirmar() + { + var publicador = new Mock<IPublicador>(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Cancelar(); + + workflow.ReProponer(); + + workflow.Agendar(); + + workflow.Confirmar(); + + publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(6)); + } + + [Test] + public void Proponer_agendar_cancelar_reagendar_y_confirmar() + { + var publicador = new Mock<IPublicador>(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Cancelar(); + + workflow.ReAgendar(); + + workflow.Confirmar(); + + publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(5)); + } + + [Test] + public void Proponer_agendar_cancelar_y_reproponer() + { + var publicador = new Mock<IPublicador>(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Cancelar(); + + workflow.ReProponer(); + + publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(4)); + } + + [Test] + public void Proponer_y_descartar() + { + var publicador = new Mock<IPublicador>(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Descartar(); + publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(2)); + } + + [Test] + public void Proponer_agendar_cancelar_y_descartar() + { + var publicador = new Mock<IPublicador>(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Cancelar(); + + workflow.Descartar(); + + publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(4)); + } + + [Test] + public void Proponer_agendar_y_confirmar() + { + var publicador = new Mock<IPublicador>(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Confirmar(); + + publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(3)); + } + + [Test] + public void Proponer_agendar_confirmar_publicar() + { + var publicador = new Mock<IPublicador>(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Confirmar(); + + workflow.Publicar(); + + publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(4)); + } + } +} \ No newline at end of file