changeset 12:05996fa19e04

Unificamos Van y Cafe en Evento Agenda.Publicar con los valores como parámetros independientes
author nelo@MTEySS.neluz.int
date Sun, 13 Mar 2011 19:50:17 -0300
parents 9d6b28a696d1
children da95298db862
files Agendas/trunk/src/Agendas.Domain/Agenda.cs Agendas/trunk/src/Agendas.Domain/Agendas.Domain.csproj Agendas/trunk/src/Agendas.Domain/Cafe.cs Agendas/trunk/src/Agendas.Domain/Evento.cs Agendas/trunk/src/Agendas.Domain/Repositories/IEventoRepository.cs Agendas/trunk/src/Agendas.Domain/Van.cs Agendas/trunk/src/Agendas.Repositories.Memory/Agendas.Repositories.Memory.csproj Agendas/trunk/src/Agendas.Repositories.Memory/CafeRepository.cs Agendas/trunk/src/Agendas.Repositories.Memory/EventoRepository.cs Agendas/trunk/src/Agendas.Repositories.Memory/VanRepository.cs Agendas/trunk/src/Agendas.Tests/AgendaTests.cs Agendas/trunk/src/Agendas.Tests/EventoObjectMother.cs Agendas/trunk/src/Agendas.Tests/EventoTests.cs Agendas/trunk/src/Agendas.Web/Controllers/AgendaController.cs
diffstat 14 files changed, 59 insertions(+), 190 deletions(-) [+]
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Domain/Agenda.cs	Sun Mar 13 19:30:58 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Domain/Agenda.cs	Sun Mar 13 19:50:17 2011 -0300
@@ -23,22 +23,20 @@
 
 		public Guid Id { get; set; }
 
-        public void Publicar(Evento evento)
+        public void Publicar(string titulo, string ponente, DateTime? fecha)
 		{
+            var evento = new Evento{Titulo=titulo, Ponente = ponente, Fecha = fecha};
+
 			if (!evento.Fecha.HasValue)
 				throw new ValidationException();
 			if (_publicador != null)
 				_publicador.Publicar(evento);
             if (NoEstaAutenticado(_seguridad))
                 throw new UsuarioNoAutenticadoException();
-            _eventosPublicados.Add(evento);
-		}
+            if (string.IsNullOrWhiteSpace(evento.Ponente))
+                throw new ValidationException();
 
-		public void Publicar(Van van)
-		{
-			if (string.IsNullOrWhiteSpace(van.Ponente))
-				throw new ValidationException();
-			Publicar(van as Evento);
+            _eventosPublicados.Add(evento);
 		}
 
 		public void Recordar(Evento evento)
@@ -47,13 +45,13 @@
 				_recordador.Recordar(evento);
 		}
 
-		public void Proponer(Van van)
+		public void Proponer(Evento evento)
 		{
-			if (string.IsNullOrWhiteSpace(van.Titulo))
+			if (string.IsNullOrWhiteSpace(evento.Titulo))
 				throw new ValidationException();
             if (NoEstaAutenticado(_seguridad))
                 throw new ValidationException();
-			_eventosPropuestos.Add(van);
+			_eventosPropuestos.Add(evento);
 		}
 
         public IList<Evento> GetEventosPropuestos()
--- a/Agendas/trunk/src/Agendas.Domain/Agendas.Domain.csproj	Sun Mar 13 19:30:58 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Domain/Agendas.Domain.csproj	Sun Mar 13 19:50:17 2011 -0300
@@ -42,7 +42,6 @@
   <ItemGroup>
     <Compile Include="Agenda.cs" />
     <Compile Include="AgendaFactory.cs" />
-    <Compile Include="Cafe.cs" />
     <Compile Include="CompositePublicador.cs" />
     <Compile Include="Evento.cs" />
     <Compile Include="Exceptions\ValidationException.cs" />
@@ -51,7 +50,6 @@
     <Compile Include="Repositories\IEventoRepository.cs" />
     <Compile Include="IPublicador.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="Van.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
--- a/Agendas/trunk/src/Agendas.Domain/Cafe.cs	Sun Mar 13 19:30:58 2011 -0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-namespace AltNetHispano.Agendas.Domain
-{
-	public class Cafe : Evento
-	{
-	}
-}
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Domain/Evento.cs	Sun Mar 13 19:30:58 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Domain/Evento.cs	Sun Mar 13 19:50:17 2011 -0300
@@ -1,12 +1,15 @@
 using System;
+using System.Collections.Generic;
 
 namespace AltNetHispano.Agendas.Domain
 {
-	public abstract class Evento
+	public class Evento
 	{
 		public Guid Id { get; set; }
 		public string Titulo { get; set; }
 		public DateTime? Fecha { get; set; }
 		public string Sintesis { get; set; }
-	}
+        public string Ponente { get; set; }
+        public IList<string> Enlaces { get; set; }
+    }
 }
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Domain/Repositories/IEventoRepository.cs	Sun Mar 13 19:30:58 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Domain/Repositories/IEventoRepository.cs	Sun Mar 13 19:50:17 2011 -0300
@@ -7,17 +7,8 @@
 		void Save(Evento evento);
 		void Delete(Evento evento);
 		void Update(Evento evento);
-	}
-
-	public interface IVanRepository : IEventoRepository
-	{
-		Van Get(Guid vanId);
-	}
-
-	public interface ICafeRepository : IEventoRepository
-	{
-		Cafe Get(Guid vanId);
-	}
+        Evento Get(Guid vanId);
+    }
 
 	public interface IAgendaRepository
 	{
--- a/Agendas/trunk/src/Agendas.Domain/Van.cs	Sun Mar 13 19:30:58 2011 -0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-using System.Collections.Generic;
-
-namespace AltNetHispano.Agendas.Domain
-{
-	public class Van : Evento
-	{
-		public string Ponente { get; set; }
-
-		public IList<string> Enlaces { get; set; }
-	}
-}
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Repositories.Memory/Agendas.Repositories.Memory.csproj	Sun Mar 13 19:30:58 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Repositories.Memory/Agendas.Repositories.Memory.csproj	Sun Mar 13 19:50:17 2011 -0300
@@ -41,11 +41,9 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="AgendaRepository.cs" />
-    <Compile Include="CafeRepository.cs" />
     <Compile Include="EventoRepository.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="RepositoryBase.cs" />
-    <Compile Include="VanRepository.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\Agendas.Domain\Agendas.Domain.csproj">
--- a/Agendas/trunk/src/Agendas.Repositories.Memory/CafeRepository.cs	Sun Mar 13 19:30:58 2011 -0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-using System;
-using AltNetHispano.Agendas.Domain;
-using AltNetHispano.Agendas.Domain.Repositories;
-
-namespace Agendas.Repositories.Memory
-{
-	public class CafeRepository : EventoRepository, ICafeRepository
-	{
-		#region ICafeRepository Members
-
-		public Cafe Get(Guid vanId)
-		{
-			Evento evento;
-			return Objects.TryGetValue(vanId, out evento) ? evento as Cafe : null;
-		}
-
-		#endregion
-	}
-}
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Repositories.Memory/EventoRepository.cs	Sun Mar 13 19:30:58 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Repositories.Memory/EventoRepository.cs	Sun Mar 13 19:50:17 2011 -0300
@@ -1,9 +1,10 @@
 using System;
 using AltNetHispano.Agendas.Domain;
+using AltNetHispano.Agendas.Domain.Repositories;
 
 namespace Agendas.Repositories.Memory
 {
-	public abstract class EventoRepository : RepositoryBase<Evento>
+	public class EventoRepository : RepositoryBase<Evento>, IEventoRepository
 	{
 		public void Save(Evento evento)
 		{
@@ -23,5 +24,12 @@
 		{
 			Objects.Remove(evento.Id);
 		}
+
+        public Evento Get(Guid vanId)
+        {
+            Evento evento;
+            return Objects.TryGetValue(vanId, out evento) ? evento : null;
+        }
+
 	}
 }
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Repositories.Memory/VanRepository.cs	Sun Mar 13 19:30:58 2011 -0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-using System;
-using AltNetHispano.Agendas.Domain;
-using AltNetHispano.Agendas.Domain.Repositories;
-
-namespace Agendas.Repositories.Memory
-{
-	public class VanRepository : EventoRepository, IVanRepository
-	{
-		#region IVanRepository Members
-
-		public Van Get(Guid vanId)
-		{
-			Evento evento;
-			return Objects.TryGetValue(vanId, out evento) ? evento as Van : null;
-		}
-
-		#endregion
-	}
-}
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Tests/AgendaTests.cs	Sun Mar 13 19:30:58 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Tests/AgendaTests.cs	Sun Mar 13 19:50:17 2011 -0300
@@ -24,18 +24,6 @@
 	    }
 
 		[Test]
-		public void Publicar_cafe()
-		{
-			var publicador = new Mock<IPublicador>();
-            var agenda = new Agenda(publicador.Object, null, SeguridadServiceDefault);
-
-			var cafe = EventoObjectMother.GetCafeValidoParaPublicar();
-			agenda.Publicar(cafe);
-
-			publicador.Verify(p => p.Publicar(It.IsAny<Evento>()), Times.Exactly(1));
-		}
-
-		[Test]
 		public void Publicar_van_con_usuario_autenticado()
 		{
 			var publicador = new Mock<IPublicador>();
@@ -44,7 +32,7 @@
 
 			var van = EventoObjectMother.GetVanValidaParaPublicar();
 
-			agenda.Publicar(van);
+			agenda.Publicar(van.Titulo, van.Ponente, van.Fecha);
 			Assert.AreEqual(1, agenda.GetEventosPublicados().Count);
 
 			publicador.Verify(p => p.Publicar(It.IsAny<Evento>()), Times.Exactly(1));
@@ -61,7 +49,7 @@
 
             seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalSinAutenticar());
 
-            Assert.Throws<UsuarioNoAutenticadoException>(() => agenda.Publicar(van));
+            Assert.Throws<UsuarioNoAutenticadoException>(() => agenda.Publicar(van.Titulo, van.Ponente, van.Fecha));
         }
 
         [Test]
@@ -73,7 +61,7 @@
 
             var van = EventoObjectMother.GetVanValidaParaPublicar();
 
-            Assert.Throws<UsuarioNoAutenticadoException>(() => agenda.Publicar(van));
+            Assert.Throws<UsuarioNoAutenticadoException>(() => agenda.Publicar(van.Titulo, van.Ponente, van.Fecha));
         }
 
 		[Test]
@@ -85,7 +73,7 @@
 			var agenda = new Agenda(publicador.Object, null, null);
 
 			var van = EventoObjectMother.GetVanValidaParaPublicar();
-			Assert.Throws<Exception>(() => agenda.Publicar(van));
+            Assert.Throws<Exception>(() => agenda.Publicar(van.Titulo, van.Ponente, van.Fecha));
 			Assert.AreEqual(0, agenda.GetEventosPublicados().Count);
 
 			publicador.Verify(p => p.Publicar(It.IsAny<Evento>()), Times.Exactly(1));
@@ -100,7 +88,7 @@
             var agenda = new Agenda(new CompositePublicador(new[] { publicador1.Object, publicador2.Object }), null, SeguridadServiceDefault);
 
 			var van = EventoObjectMother.GetVanValidaParaPublicar();
-			agenda.Publicar(van);
+            agenda.Publicar(van.Titulo, van.Ponente, van.Fecha);
 
 			publicador1.Verify(p => p.Publicar(It.IsAny<Evento>()), Times.Exactly(1));
 			publicador2.Verify(p => p.Publicar(It.IsAny<Evento>()), Times.Exactly(1));
@@ -116,7 +104,7 @@
             var agenda = new Agenda(new CompositePublicador(new[] { publicador1.Object, publicador2.Object }), recordador1.Object, SeguridadServiceDefault);
 
 			var van = EventoObjectMother.GetVanValidaParaPublicar();
-			agenda.Publicar(van);
+            agenda.Publicar(van.Titulo, van.Ponente, van.Fecha);
 
 			agenda.Recordar(van);
 
@@ -130,7 +118,7 @@
 		[Test]
 		public void Propuesta_de_van_con_usuario_autenticado()
 		{
-			var van = new Van{Titulo = "Van propuesta"};
+			var van = new Evento{Titulo = "Van propuesta"};
 
             var seguridad = new Mock<ISeguridad>();
             var agenda = new Agenda(null, null, seguridad.Object);
@@ -150,12 +138,12 @@
             var seguridad = new Mock<ISeguridad>();
             var agenda = new Agenda(null, null, seguridad.Object);
 
-            var vanPropuesta = new Van { Titulo = "Van propuesta" };
+            var vanPropuesta = new Evento { Titulo = "Van propuesta" };
             var vanPublicada = EventoObjectMother.GetVanValidaParaPublicar();
             seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
 
             agenda.Proponer(vanPropuesta);
-            agenda.Publicar(vanPublicada);
+            agenda.Publicar(vanPublicada.Titulo, vanPublicada.Ponente, vanPublicada.Fecha);
 
             IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
             IList<Evento> eventosPublicados = agenda.GetEventosPublicados();
@@ -167,7 +155,7 @@
 		[Test]
 		public void Propuesta_de_van_sin_titulo()
 		{
-			var van = new Van();
+			var van = new Evento();
 
             var seguridad = new Mock<ISeguridad>();
             var agenda = new Agenda(null, null, seguridad.Object);
@@ -185,14 +173,14 @@
             seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
 
 			{
-				var van = new Van {Titulo = "Van propuesta"};
+				var van = new Evento {Titulo = "Van propuesta"};
                 agenda.Proponer(van);
 			}
 
 			{
 				var van = agenda.GetEventosPropuestos().FirstOrDefault();
 				Assert.IsNotNull(van);
-				Assert.Throws<ValidationException>(()=>agenda.Publicar(van));
+                Assert.Throws<ValidationException>(() => agenda.Publicar(van.Titulo, van.Ponente, van.Fecha));
 			}
 		}
 
@@ -205,26 +193,28 @@
             seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
 
 			{
-				var van = new Van { Titulo = "Van propuesta" };
+				var van = new Evento { Titulo = "Van propuesta" };
                 agenda.Proponer(van);
 			}
 
 			{
-				var van = agenda.GetEventosPropuestos().FirstOrDefault() as Van;
+				var van = agenda.GetEventosPropuestos().FirstOrDefault();
 				Assert.IsNotNull(van);
 
 				van.Fecha = DateTime.Today.AddDays(5);
-				Assert.Throws<ValidationException>(() => agenda.Publicar(van));
+                Assert.Throws<ValidationException>(() => agenda.Publicar(van.Titulo, van.Ponente, van.Fecha));
 			}
 		}
 
 		[Test]
 		public void Van_crud()
 		{
-			Guid vanId;
+            var van = EventoObjectMother.GetVanValidaParaPublicar();
+            
+            Guid vanId;
 			{
                 var agenda = new Agenda(null, null, SeguridadServiceDefault);
-				agenda.Publicar(EventoObjectMother.GetVanValidaParaPublicar());
+                agenda.Publicar(van.Titulo, van.Ponente, van.Fecha);
 
 				IAgendaRepository agendaRepository = new AgendaRepository();
 
@@ -239,7 +229,7 @@
 
 				Assert.IsNotNull(agenda);
 				Assert.AreEqual(1, agenda.GetEventosPublicados().Count);
-				agenda.Publicar(EventoObjectMother.GetCafeValidoParaPublicar());
+                agenda.Publicar(van.Titulo, van.Ponente, van.Fecha);
 
 				agendaRepository.Update(agenda);
 			}
--- a/Agendas/trunk/src/Agendas.Tests/EventoObjectMother.cs	Sun Mar 13 19:30:58 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Tests/EventoObjectMother.cs	Sun Mar 13 19:50:17 2011 -0300
@@ -5,14 +5,9 @@
 {
 	public static class EventoObjectMother
 	{
-		public static Van GetVanValidaParaPublicar()
-		{
-			return new Van {Fecha = DateTime.Now, Ponente = "jjmontes"};
-		}
-
-		public static Cafe GetCafeValidoParaPublicar()
-		{
-			return new Cafe { Fecha = DateTime.Now };
-		}
-	}
+        public static Evento GetVanValidaParaPublicar()
+        {
+            return new Evento { Fecha = DateTime.Now, Ponente = "jjmontes" };
+        }
+    }
 }
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Tests/EventoTests.cs	Sun Mar 13 19:30:58 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Tests/EventoTests.cs	Sun Mar 13 19:50:17 2011 -0300
@@ -10,72 +10,17 @@
 	public class EventoTests
 	{
 		[Test]
-		public void Cafe_crud()
-		{
-			Guid cafeId;
-			{
-				var cafe = new Cafe
-				           	{
-				           		Titulo = "La Inmortalidad de la Medusa - Arquitectura",
-				           		Fecha = new DateTime(2010, 08, 27),
-				           	};
-				ICafeRepository eventoRepository = new CafeRepository();
-
-				eventoRepository.Save(cafe);
-				cafeId = cafe.Id;
-			}
-
-			const string sintesis =
-				"Se habló sobre la sensación de perdida de control con el uso de frameworks, la Organización en capas de una aplicación, servicios en la web que se combinan.\nSe discutió un poco sobre Testing Unitario vs Test de Integración. Testing con Stubs vs Mocks, la diferencia entre decir que debe hacer un componente y como debe hacerlo.\nSe habló sobre MVVM.";
-
-			{
-				ICafeRepository eventoRepository = new CafeRepository();
-
-				Cafe cafe = eventoRepository.Get(cafeId);
-
-				Assert.IsNotNull(cafe);
-				Assert.AreEqual("La Inmortalidad de la Medusa - Arquitectura", cafe.Titulo);
-				Assert.AreEqual(new DateTime(2010, 08, 27), cafe.Fecha);
-
-				cafe.Sintesis = sintesis;
-
-				eventoRepository.Update(cafe);
-			}
-
-			{
-				ICafeRepository eventoRepository = new CafeRepository();
-
-				Cafe cafe = eventoRepository.Get(cafeId);
-
-				Assert.IsNotNull(cafe);
-				Assert.AreEqual("La Inmortalidad de la Medusa - Arquitectura", cafe.Titulo);
-				Assert.AreEqual(new DateTime(2010, 08, 27), cafe.Fecha);
-				Assert.AreEqual(sintesis, cafe.Sintesis);
-
-				eventoRepository.Delete(cafe);
-			}
-
-			{
-				ICafeRepository eventoRepository = new CafeRepository();
-
-				Cafe cafe = eventoRepository.Get(cafeId);
-
-				Assert.IsNull(cafe);
-			}
-		}
-
-		[Test]
 		public void Van_crud()
 		{
 			Guid vanId;
 			{
-				var van = new Van
+				var van = new Evento
 				          	{
 				          		Titulo = "TDD - Diseño Basado en Ejemplos",
 				          		Ponente = "Carlos Blé",
 				          		Fecha = new DateTime(2010, 04, 16)
 				          	};
-				IVanRepository eventoRepository = new VanRepository();
+				IEventoRepository eventoRepository = new EventoRepository();
 
 				eventoRepository.Save(van);
 				vanId = van.Id;
@@ -85,9 +30,9 @@
 				"Durante la primera hora se habló de los principios SOLID, de BDD, TDD y ATDD. Discusión entre las diferencias entre TDD y BDD, así como también sobre algunas cuestiones relativas a la nomenclatura.\n Durante la segunda hora se realizó un ejercicio práctico demostrando como se comienza a practicar TDD.\n La última parte de la VAN es la mas interesante respecto a lo que es TDD y como se practica.";
 
 			{
-				IVanRepository eventoRepository = new VanRepository();
+				IEventoRepository eventoRepository = new EventoRepository();
 
-				Van van = eventoRepository.Get(vanId);
+				Evento van = eventoRepository.Get(vanId);
 
 				Assert.IsNotNull(van);
 				Assert.AreEqual("Carlos Blé", van.Ponente);
@@ -102,9 +47,9 @@
 			}
 
 			{
-				IVanRepository eventoRepository = new VanRepository();
+				IEventoRepository eventoRepository = new EventoRepository();
 
-				Van van = eventoRepository.Get(vanId);
+				Evento van = eventoRepository.Get(vanId);
 
 				Assert.IsNotNull(van);
 				Assert.AreEqual("Carlos Blé", van.Ponente);
@@ -120,9 +65,9 @@
 			}
 
 			{
-				IVanRepository eventoRepository = new VanRepository();
+				IEventoRepository eventoRepository = new EventoRepository();
 
-				Van van = eventoRepository.Get(vanId);
+				Evento van = eventoRepository.Get(vanId);
 
 				Assert.IsNull(van);
 			}
--- a/Agendas/trunk/src/Agendas.Web/Controllers/AgendaController.cs	Sun Mar 13 19:30:58 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Controllers/AgendaController.cs	Sun Mar 13 19:50:17 2011 -0300
@@ -41,7 +41,7 @@
 
                 try
                 {
-                    agenda.Publicar(new Van {Titulo = model.Titulo, Ponente = model.Ponente, Fecha = model.Fecha});
+                    agenda.Publicar(model.Titulo, model.Ponente, model.Fecha);
 
                     return View("Index", GetIndexModel());
                 }
@@ -52,7 +52,5 @@
             }
             return View(model);
         }
-
-        
     }
 }