Mercurial > altnet-hispano
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 | 1 using System; |
67
c8099df941bd
Implementando persistencia con NHibernate en el proyecto web
nelopauselli
parents:
63
diff
changeset
|
2 using Agendas.NHibernate; |
63 | 3 using AltNetHispano.Agendas.Domain; |
4 using AltNetHispano.Agendas.Repositories.NHibernate; | |
5 using Moq; | |
6 using NHibernate; | |
7 using NHibernate.Cfg; | |
8 using NHibernate.Context; | |
9 using NHibernate.Tool.hbm2ddl; | |
10 using NUnit.Framework; | |
11 | |
12 namespace AltNetHispano.Agendas.Tests.Cruds | |
13 { | |
14 [TestFixture] | |
15 public class EventoCrudNhTests | |
16 { | |
17 private EventoCrud _eventoCrud; | |
18 | |
19 #region SetUp | |
20 | |
21 [SetUp] | |
22 public void BorrarRepositorios() | |
23 { | |
24 Configuration cfg =NhHelper.GetConfiguration(); | |
25 var schemaExport = new SchemaExport(cfg); | |
26 schemaExport.Create(false, true); | |
27 } | |
28 | |
29 [SetUp] | |
30 public void SetearUsuario() | |
31 { | |
32 var seguridad = new Mock<ISeguridad>(); | |
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 | 35 } |
36 | |
37 [SetUp] | |
38 public void CreateCrud() | |
39 { | |
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 | 42 () => new RequestEmulator(sessionFactory)); |
43 } | |
44 | |
45 #endregion | |
46 | |
47 [Test] | |
48 public void Create() | |
49 { | |
50 _eventoCrud.Create(); | |
51 } | |
52 | |
53 [Test] | |
54 public void Read() | |
55 { | |
56 _eventoCrud.Read(); | |
57 } | |
58 | |
59 [Test] | |
60 public void Update() | |
61 { | |
62 _eventoCrud.Update(); | |
63 } | |
64 | |
65 [Test] | |
66 public void Delete() | |
67 { | |
68 _eventoCrud.Delete(); | |
69 } | |
70 | |
71 } | |
72 | |
73 public class RequestEmulator : IDisposable | |
74 { | |
75 private readonly ISession _session; | |
76 | |
77 public RequestEmulator(ISessionFactory sessionFactory) | |
78 { | |
79 _session = sessionFactory.OpenSession(); | |
80 CurrentSessionContext.Bind(_session); | |
81 } | |
82 | |
83 public void Dispose() | |
84 { | |
85 _session.Flush(); | |
86 _session.Close(); | |
87 } | |
88 } | |
89 } |