annotate Agendas/trunk/src/Agendas.Tests/PropuestasTests.cs @ 24:41b283d27e3e

Ponentes como entidad Agenda no es una entidad persistente (por ahora)
author nelo@MTEySS.neluz.int
date Tue, 15 Mar 2011 07:49:53 -0300
parents d6e124e5c9c4
children 71b02443450a
rev   line source
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
1 using System;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
2 using System.Collections.Generic;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
3 using System.Linq;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
4 using AltNetHispano.Agendas.Domain;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
5 using AltNetHispano.Agendas.Domain.Exceptions;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
6 using AltNetHispano.Agendas.Domain.Repositories;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
7 using Moq;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
8 using NUnit.Framework;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
9
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
10 namespace AltNetHispano.Agendas.Tests
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
11 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
12 [TestFixture]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
13 public class PropuestasTests : TestBase
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
14 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
15 [Test]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
16 public void Propuesta_de_van_con_usuario_autenticado()
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
17 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
18 var seguridad = new Mock<ISeguridad>();
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 22
diff changeset
19 var agenda = new Agenda(null, null, seguridad.Object, DefaultEventoRepository, DefaultPonenteRepository);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
21 seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 20
diff changeset
22 agenda.Proponer("Van propuesta");
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
23
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
24 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
25 Assert.IsNotNull(eventosPropuestos);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
26 Assert.AreEqual(1, eventosPropuestos.Count);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
27 Assert.AreEqual("Van propuesta", eventosPropuestos[0].Titulo);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
28 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
29
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
30 [Test]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
31 public void Verificar_propuesta_separada_de_publicacion()
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
32 {
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 22
diff changeset
33 var agenda = new Agenda(null, null, SeguridadServiceDefault, DefaultEventoRepository, DefaultPonenteRepository);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
34
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 20
diff changeset
35 agenda.Proponer("Van propuesta");
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 22
diff changeset
36 agenda.Publicar("Van publicada", "jjmontes", DateTime.Now);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
37
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
38 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
39 IList<Evento> eventosPublicados = agenda.GetEventosPublicados();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
40
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
41 Assert.AreEqual(1, eventosPropuestos.Count);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
42 Assert.AreEqual(1, eventosPublicados.Count);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
43 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
44
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
45 [Test]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
46 public void Propuesta_de_van_sin_titulo()
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
47 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
48 var repository = new Mock<IEventoRepository>();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
49
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
50 var seguridad = new Mock<ISeguridad>();
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 22
diff changeset
51 var agenda = new Agenda(null, null, seguridad.Object, repository.Object, DefaultPonenteRepository);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
52
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 20
diff changeset
53 Assert.Throws<ValidationException>(() => agenda.Proponer(string.Empty));
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
54
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
55 repository.Verify(p => p.Save(It.IsAny<Evento>()), Times.Exactly(0));
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
56 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
57
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
58 [Test]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
59 public void Agendar_van_propuesta_sin_fecha()
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
60 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
61 var seguridad = new Mock<ISeguridad>();
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 22
diff changeset
62 var agenda = new Agenda(null, null, seguridad.Object, DefaultEventoRepository, DefaultPonenteRepository);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
63
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
64 seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
65
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
66 {
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 20
diff changeset
67 agenda.Proponer("Van propuesta");
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
68 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
69
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
70 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
71 var van = agenda.GetEventosPropuestos().FirstOrDefault();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
72 Assert.IsNotNull(van);
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 22
diff changeset
73 Assert.Throws<ValidationException>(() => agenda.Publicar(van.Titulo, string.Empty, van.Fecha));
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
74 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
75 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
76
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
77 [Test]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
78 public void Agendar_van_propuesta_sin_ponente()
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
79 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
80 var seguridad = new Mock<ISeguridad>();
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 22
diff changeset
81 var agenda = new Agenda(null, null, seguridad.Object, DefaultEventoRepository, DefaultPonenteRepository);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
82
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
83 seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
84
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
85 {
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 20
diff changeset
86 agenda.Proponer("Van propuesta");
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
87 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
88
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
89 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
90 var van = agenda.GetEventosPropuestos().FirstOrDefault();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
91 Assert.IsNotNull(van);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
92
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
93 van.Fecha = DateTime.Today.AddDays(5);
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 22
diff changeset
94 Assert.Throws<ValidationException>(() => agenda.Publicar(van.Titulo, string.Empty, van.Fecha));
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
95 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
96 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
97 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
98 }