diff Agendas/trunk/src/Agendas.Tests/Workflows/WorkflowTests.cs @ 81:c76661cff260

Workflow de acciones sobre un evento (camino feliz)
author nelopauselli
date Tue, 24 May 2011 19:21:20 -0300
parents
children 26d0513a8410
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Tests/Workflows/WorkflowTests.cs	Tue May 24 19:21:20 2011 -0300
@@ -0,0 +1,70 @@
+using System.Linq;
+using AltNetHispano.Agendas.Domain;
+using Moq;
+using NUnit.Framework;
+
+namespace AltNetHispano.Agendas.Tests.Workflows
+{
+	[TestFixture]
+	public class WorkflowTests : TestBase
+	{
+		private Mock<IPublicador> _publicador;
+		private Workflow _workflow;
+
+		[SetUp]
+		public void InitPublicador()
+		{
+			_publicador = new Mock<IPublicador>();
+			_workflow = new Workflow(_publicador.Object, DefaultEventoRepository, DefaultPonenteRepository);
+		}
+
+		[Test]
+		public void Proponer()
+		{
+			_workflow.Proponer();
+			_publicador.Verify(p => p.Publicar(It.IsAny<Evento>()), Times.Once());
+		}
+
+		[Test]
+		public void Proponer_y_agendar()
+		{
+			_workflow.Proponer();
+
+			_workflow.Agendar();
+
+			_publicador.Verify(p => p.Publicar(It.IsAny<Evento>()), Times.Exactly(2));
+		}
+
+		[Test]
+		public void Proponer_agendar_y_confirmar()
+		{
+			_workflow.Proponer();
+
+			_workflow.Agendar();
+
+			var evento = DefaultEventoRepository.GetEventosConFecha().SingleOrDefault();
+			Assert.IsNotNull(evento);
+
+			_workflow.Confirmar(evento.Id);
+
+			_publicador.Verify(p => p.Publicar(It.IsAny<Evento>()), Times.Exactly(3));
+		}
+
+		[Test]
+		public void Proponer_agendar_confirmar_publicar()
+		{
+			_workflow.Proponer();
+
+			_workflow.Agendar();
+
+			var evento = DefaultEventoRepository.GetEventosConFecha().SingleOrDefault();
+			Assert.IsNotNull(evento);
+
+			_workflow.Confirmar(evento.Id);
+
+			_workflow.Publicar(evento.Id);
+
+			_publicador.Verify(p => p.Publicar(It.IsAny<Evento>()), Times.Exactly(4));
+		}
+	}
+}
\ No newline at end of file