annotate Agendas/trunk/src/Agendas.Tests/EventoTests.cs @ 8:cae27d7eb697

Se agregó ISeguridad para validar autenticaciones de usuarios. Agenda.Proponer modificado para validar que solo pueden Proponer eventos los usuarios autenticados.
author juanjose.montesdeocaarbos
date Sat, 12 Feb 2011 11:12:18 -0300
parents 5f007e266509
children 05996fa19e04
rev   line source
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
1 using System;
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
2 using Agendas.Repositories.Memory;
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
3 using AltNetHispano.Agendas.Domain;
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
4 using AltNetHispano.Agendas.Domain.Repositories;
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
5 using NUnit.Framework;
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
6
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
7 namespace AltNetHispano.Agendas.Tests
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
8 {
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
9 [TestFixture]
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
10 public class EventoTests
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
11 {
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
12 [Test]
3
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
13 public void Cafe_crud()
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
14 {
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
15 Guid cafeId;
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
16 {
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
17 var cafe = new Cafe
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
18 {
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
19 Titulo = "La Inmortalidad de la Medusa - Arquitectura",
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
20 Fecha = new DateTime(2010, 08, 27),
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
21 };
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
22 ICafeRepository eventoRepository = new CafeRepository();
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
23
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
24 eventoRepository.Save(cafe);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
25 cafeId = cafe.Id;
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
26 }
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
27
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
28 const string sintesis =
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
29 "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.";
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
30
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
31 {
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
32 ICafeRepository eventoRepository = new CafeRepository();
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
33
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
34 Cafe cafe = eventoRepository.Get(cafeId);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
35
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
36 Assert.IsNotNull(cafe);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
37 Assert.AreEqual("La Inmortalidad de la Medusa - Arquitectura", cafe.Titulo);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
38 Assert.AreEqual(new DateTime(2010, 08, 27), cafe.Fecha);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
39
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
40 cafe.Sintesis = sintesis;
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
41
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
42 eventoRepository.Update(cafe);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
43 }
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
44
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
45 {
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
46 ICafeRepository eventoRepository = new CafeRepository();
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
47
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
48 Cafe cafe = eventoRepository.Get(cafeId);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
49
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
50 Assert.IsNotNull(cafe);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
51 Assert.AreEqual("La Inmortalidad de la Medusa - Arquitectura", cafe.Titulo);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
52 Assert.AreEqual(new DateTime(2010, 08, 27), cafe.Fecha);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
53 Assert.AreEqual(sintesis, cafe.Sintesis);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
54
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
55 eventoRepository.Delete(cafe);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
56 }
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
57
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
58 {
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
59 ICafeRepository eventoRepository = new CafeRepository();
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
60
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
61 Cafe cafe = eventoRepository.Get(cafeId);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
62
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
63 Assert.IsNull(cafe);
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
64 }
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
65 }
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
66
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
67 [Test]
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents: 1
diff changeset
68 public void Van_crud()
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
69 {
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
70 Guid vanId;
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
71 {
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
72 var van = new Van
3
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
73 {
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
74 Titulo = "TDD - Diseño Basado en Ejemplos",
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
75 Ponente = "Carlos Blé",
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
76 Fecha = new DateTime(2010, 04, 16)
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
77 };
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents: 1
diff changeset
78 IVanRepository eventoRepository = new VanRepository();
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
79
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
80 eventoRepository.Save(van);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
81 vanId = van.Id;
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
82 }
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
83
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
84 const string sintesis =
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
85 "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.";
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
86
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
87 {
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents: 1
diff changeset
88 IVanRepository eventoRepository = new VanRepository();
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
89
3
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
90 Van van = eventoRepository.Get(vanId);
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
91
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
92 Assert.IsNotNull(van);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
93 Assert.AreEqual("Carlos Blé", van.Ponente);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
94 Assert.AreEqual("TDD - Diseño Basado en Ejemplos", van.Titulo);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
95 Assert.AreEqual(new DateTime(2010, 04, 16), van.Fecha);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
96
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
97 van.Sintesis = sintesis;
3
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
98 van.Enlaces = new[] {"www.carlosble.com", "www.dirigidoPorTests.com"};
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
99 van.Fecha = new DateTime(2010, 04, 17);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
100
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
101 eventoRepository.Update(van);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
102 }
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
103
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
104 {
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents: 1
diff changeset
105 IVanRepository eventoRepository = new VanRepository();
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
106
3
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
107 Van van = eventoRepository.Get(vanId);
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
108
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
109 Assert.IsNotNull(van);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
110 Assert.AreEqual("Carlos Blé", van.Ponente);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
111 Assert.AreEqual("TDD - Diseño Basado en Ejemplos", van.Titulo);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
112 Assert.AreEqual(new DateTime(2010, 04, 17), van.Fecha);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
113 Assert.AreEqual(sintesis, van.Sintesis);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
114 Assert.IsNotNull(van.Enlaces);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
115 Assert.AreEqual(2, van.Enlaces.Count);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
116 Assert.AreEqual("www.carlosble.com", van.Enlaces[0]);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
117 Assert.AreEqual("www.dirigidoPorTests.com", van.Enlaces[1]);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
118
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
119 eventoRepository.Delete(van);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
120 }
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
121
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
122 {
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents: 1
diff changeset
123 IVanRepository eventoRepository = new VanRepository();
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
124
3
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
125 Van van = eventoRepository.Get(vanId);
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
126
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
127 Assert.IsNull(van);
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
128 }
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
129 }
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
130 }
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents:
diff changeset
131 }