annotate Agendas/trunk/src/Agendas.Tests/Cruds/EventoCrudNhTests.cs @ 126:6012f2becf97

Se agrega instalación de nuget package para el calendario de google.
author alabra
date Tue, 28 Jun 2011 23:35:22 -0400
parents db4b1e2cae49
children 2d1adbaf0373
rev   line source
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
1 using System;
67
c8099df941bd Implementando persistencia con NHibernate en el proyecto web
nelopauselli
parents: 63
diff changeset
2 using Agendas.NHibernate;
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
3 using AltNetHispano.Agendas.Domain;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
4 using AltNetHispano.Agendas.Repositories.NHibernate;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
5 using Moq;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
6 using NHibernate;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
7 using NHibernate.Cfg;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
8 using NHibernate.Context;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
9 using NHibernate.Tool.hbm2ddl;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
10 using NUnit.Framework;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
11
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
12 namespace AltNetHispano.Agendas.Tests.Cruds
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
13 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
14 [TestFixture]
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
15 public class EventoCrudNhTests
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
16 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
17 private EventoCrud _eventoCrud;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
18
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
19 #region SetUp
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
20
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
21 [SetUp]
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
22 public void BorrarRepositorios()
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
23 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
24 Configuration cfg =NhHelper.GetConfiguration();
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
25 var schemaExport = new SchemaExport(cfg);
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
26 schemaExport.Create(false, true);
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
27 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
28
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
29 [SetUp]
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
30 public void SetearUsuario()
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
31 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
32 var seguridad = new Mock<ISeguridad>();
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
33 seguridad.Setup(s => s.GetUserName()).Returns("neluz");
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 67
diff changeset
34 IdentityContext.Init(seguridad.Object, new PersonaRepository(NhHelper.GetSessionFactory()));
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
35 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
36
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
37 [SetUp]
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
38 public void CreateCrud()
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
39 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
40 ISessionFactory sessionFactory=NhHelper.GetSessionFactory();
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 67
diff changeset
41 _eventoCrud = new EventoCrud(() => new EventoRepository(sessionFactory), () => new PersonaRepository(sessionFactory),
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
42 () => new RequestEmulator(sessionFactory));
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
43 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
44
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
45 #endregion
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
46
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
47 [Test]
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
48 public void Create()
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
49 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
50 _eventoCrud.Create();
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
51 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
52
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
53 [Test]
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
54 public void Read()
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
55 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
56 _eventoCrud.Read();
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
57 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
58
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
59 [Test]
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
60 public void Update()
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
61 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
62 _eventoCrud.Update();
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
63 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
64
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
65 [Test]
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
66 public void Delete()
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
67 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
68 _eventoCrud.Delete();
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
69 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
70
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
71 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
72
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
73 public class RequestEmulator : IDisposable
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
74 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
75 private readonly ISession _session;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
76
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
77 public RequestEmulator(ISessionFactory sessionFactory)
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
78 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
79 _session = sessionFactory.OpenSession();
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
80 CurrentSessionContext.Bind(_session);
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
81 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
82
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
83 public void Dispose()
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
84 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
85 _session.Flush();
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
86 _session.Close();
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
87 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
88 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
89 }