annotate Agendas/trunk/src/Agendas.Repositories.Tests/PatrocinadorCrud.cs @ 275:bf993f99cee3

Ticket #123: Patrocinadores de las vans.
author juanjose.montesdeocaarbos
date Wed, 14 Dec 2011 08:15:44 -0300
parents 72a96459f910
children 9bc60d166c8a
rev   line source
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
1 using System;
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
2 using AltNetHispano.Agendas.Domain;
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
3 using AltNetHispano.Agendas.Domain.Repositories;
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
4 using NUnit.Framework;
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
5
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
6 namespace Agendas.Repositories.Tests
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
7 {
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
8 public class PatrocinadorCrud
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
9 {
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
10 private readonly IPatrocinadorRepository _patrocinadorRepository;
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
11 private readonly Func<IDisposable> _requestEmulator;
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
12 private byte[] _logo;
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
13
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
14 public PatrocinadorCrud(Func<IPatrocinadorRepository> createPatrocinadorRepository, Func<IDisposable> requestEmulator)
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
15 {
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
16 _patrocinadorRepository = createPatrocinadorRepository.Invoke();
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
17 _requestEmulator = requestEmulator;
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
18 }
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
19
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
20 public Guid Create()
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
21 {
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
22 using (_requestEmulator.Invoke())
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
23 {
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
24 var patrocinador = new Patrocinador("APRESS");
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
25
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
26 patrocinador.LoadLogo("images/apress.gif");
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
27 _logo = patrocinador.Logo;
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
28
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
29 _patrocinadorRepository.Save(patrocinador);
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
30 return patrocinador.Id;
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
31 }
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
32 }
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
33
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
34 public void Read()
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
35 {
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
36 Guid patrocinadorId = Create();
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
37
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
38 using (_requestEmulator.Invoke())
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
39 {
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
40 var patrocinador = _patrocinadorRepository.Get(patrocinadorId);
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
41
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
42 Assert.IsNotNull(patrocinador);
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
43 Assert.AreEqual("APRESS", patrocinador.Nombre);
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
44 Assert.IsNotNull(patrocinador.Logo);
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
45 Assert.AreEqual(_logo, patrocinador.Logo);
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
46 }
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
47 }
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
48
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
49 public void Update()
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
50 {
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
51 Guid patrocinadorId = Create();
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
52
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
53 using (_requestEmulator.Invoke())
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
54 {
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
55 var patrocinador = _patrocinadorRepository.Get(patrocinadorId);
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
56 Assert.IsNotNull(patrocinador);
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
57
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
58 patrocinador.Nombre = "Apress";
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
59 }
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
60
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
61 using (_requestEmulator.Invoke())
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
62 {
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
63 var patrocinador = _patrocinadorRepository.Get(patrocinadorId);
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
64
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
65 Assert.IsNotNull(patrocinador);
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
66 Assert.AreEqual("Apress", patrocinador.Nombre);
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
67 }
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
68 }
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
69
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
70 public void Delete()
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
71 {
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
72 Guid patrocinadorId = Create();
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
73
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
74 using (_requestEmulator.Invoke())
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
75 {
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
76 var patrocinador = _patrocinadorRepository.Get(patrocinadorId);
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
77 Assert.IsNotNull(patrocinador);
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
78
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
79 _patrocinadorRepository.Delete(patrocinador);
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
80 }
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
81
274
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
82 using (_requestEmulator.Invoke())
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
83 {
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
84 var patrocinador = _patrocinadorRepository.Get(patrocinadorId);
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
85 Assert.IsNull(patrocinador);
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
86 }
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
87 }
72a96459f910 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents: 222
diff changeset
88 }
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents:
diff changeset
89 }