changeset 63:963b71ea6028

Repositorios con NH
author nelopauselli
date Tue, 17 May 2011 14:02:25 -0300
parents c40b97bbed01
children 240a20cdbcc8
files Agendas/trunk/src/Agendas.Domain/Evento.cs Agendas/trunk/src/Agendas.Domain/Identificable.cs Agendas/trunk/src/Agendas.Domain/Ponente.cs Agendas/trunk/src/Agendas.Domain/Track.cs Agendas/trunk/src/Agendas.Repositories.NHibernate/Agendas.Repositories.NHibernate.csproj Agendas/trunk/src/Agendas.Repositories.NHibernate/EventoRepository.cs Agendas/trunk/src/Agendas.Repositories.NHibernate/NhHelper.cs Agendas/trunk/src/Agendas.Repositories.NHibernate/PonenteRepository.cs Agendas/trunk/src/Agendas.Repositories.NHibernate/Properties/AssemblyInfo.cs Agendas/trunk/src/Agendas.Repositories.NHibernate/RepositoryBase.cs Agendas/trunk/src/Agendas.Repositories.NHibernate/packages.config Agendas/trunk/src/Agendas.Tests/Agendas.Tests.csproj Agendas/trunk/src/Agendas.Tests/App.config Agendas/trunk/src/Agendas.Tests/Cruds/EventoCrudNhTests.cs Agendas/trunk/src/Agendas.Tests/Cruds/EventoTests.cs Agendas/trunk/src/Agendas.Tests/hibernate.cfg.xml Agendas/trunk/src/Agendas.Tests/packages.config Agendas/trunk/src/Agendas.sln Agendas/trunk/src/install packages.bat
diffstat 19 files changed, 455 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Domain/Evento.cs	Tue May 17 01:55:19 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Domain/Evento.cs	Tue May 17 14:02:25 2011 -0300
@@ -24,18 +24,18 @@
 			return evento;
 		}
 
-		private Evento()
+		protected Evento()
 		{
 			_enlaces = new List<string>();
 			_tracks = new List<Track>();
 		}
 
-		public string Titulo { get; private set; }
-		public DateTime? Fecha { get; private set; }
-		public string Sintesis { get; private set; }
+		public virtual string Titulo { get; private set; }
+		public virtual DateTime? Fecha { get; private set; }
+		public virtual string Sintesis { get; private set; }
 		
 		private Ponente _ponente;
-		public Ponente Ponente
+		public virtual Ponente Ponente
 		{
 			get { return _ponente; }
 			private set
@@ -48,17 +48,17 @@
 			}
 		}
 
-		public IEnumerable<string> Enlaces
+		public virtual IEnumerable<string> Enlaces
 		{
 			get { return _enlaces; }
 		}
 
-		public IEnumerable<Track> Tracks
+		public virtual IEnumerable<Track> Tracks
 		{
 			get { return _tracks; }
 		}
 
-		public void Actualizar(Ponente ponente, DateTime? fecha)
+		public virtual void Actualizar(Ponente ponente, DateTime? fecha)
 		{
 			Ponente = ponente;
 			Fecha = fecha;
@@ -66,27 +66,27 @@
 			AddTracks(new Track(Accion.Modificar));
 		}
 
-		public void CambiarTitulo(string titulo)
+		public virtual void CambiarTitulo(string titulo)
 		{
 			Titulo = titulo;
 			AddTracks(new Track(Accion.CambiarTitulo));
 		}
 
-		public void Publicar(Ponente ponente, DateTime? fecha)
+		public virtual void Publicar(Ponente ponente, DateTime? fecha)
 		{
 			Ponente = ponente;
 			Fecha = fecha;
 			AddTracks(new Track(Accion.Publicar));
 		}
 
-		public void Realizado(DateTime fecha, string sintesis, IList<string> enlaces)
+		public virtual void Realizado(DateTime fecha, string sintesis, IList<string> enlaces)
 		{
 			Fecha = fecha;
 			Sintesis = sintesis;
 			_enlaces = enlaces;
 		}
 
-		public void Realizado(string sintesis)
+		public virtual void Realizado(string sintesis)
 		{
 			Sintesis = sintesis;
 			AddTracks(new Track(Accion.Realizar));
--- a/Agendas/trunk/src/Agendas.Domain/Identificable.cs	Tue May 17 01:55:19 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Domain/Identificable.cs	Tue May 17 14:02:25 2011 -0300
@@ -4,6 +4,6 @@
 {
 	public class Identificable
 	{
-		public Guid Id { get; private set; }
+		public virtual Guid Id { get; private set; }
 	}
 }
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Domain/Ponente.cs	Tue May 17 01:55:19 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Domain/Ponente.cs	Tue May 17 14:02:25 2011 -0300
@@ -7,6 +7,11 @@
 	{
 		private readonly IList<Evento> _eventos;
 
+		protected Ponente()
+		{
+			//ctor para NHibernate
+		}
+
 		public Ponente(string nombre, string mail, string twitter, string blog)
 			: this(nombre)
 		{
@@ -21,26 +26,26 @@
 			_eventos = new List<Evento>();
 		}
 
-		public string Nombre { get; private set; }
+		public virtual string Nombre { get; private set; }
 
-		public string Mail { get; private set; }
+		public virtual string Mail { get; private set; }
 
-		public string Twitter { get; private set; }
+		public virtual string Twitter { get; private set; }
 
-		public string Blog { get; private set; }
+		public virtual string Blog { get; private set; }
 
-		public IEnumerable<Evento> Eventos
+		public virtual IEnumerable<Evento> Eventos
 		{
 			get { return _eventos; }
 		}
 
-		public void AddEvento(Evento evento)
+		public virtual void AddEvento(Evento evento)
 		{
 			if (!_eventos.Contains(evento))
 				_eventos.Add(evento);
 		}
 
-		public void RemoveEvento(Evento evento)
+		public virtual void RemoveEvento(Evento evento)
 		{
 			if (_eventos.Contains(evento))
 				_eventos.Remove(evento);
--- a/Agendas/trunk/src/Agendas.Domain/Track.cs	Tue May 17 01:55:19 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Domain/Track.cs	Tue May 17 14:02:25 2011 -0300
@@ -2,14 +2,19 @@
 {
 	public class Track
 	{
+		protected Track()
+		{
+			//ctor para NHibernate
+		}
+
 		public Track(Accion accion)
 		{
 			Usuario = IdentityContext.GetUserName();
 			Accion = accion;
 		}
 
-		public Accion Accion { get; private set; }
-		protected string Usuario { get; private set; }
+		public virtual Accion Accion { get; private set; }
+		protected virtual string Usuario { get; private set; }
 	}
 
 	public enum Accion
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Repositories.NHibernate/Agendas.Repositories.NHibernate.csproj	Tue May 17 14:02:25 2011 -0300
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{0973DF44-3B90-4D2A-B579-C64C93B6C853}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>AltNetHispano.Agendas.Repositories.NHibernate</RootNamespace>
+    <AssemblyName>AltNetHispano.Agendas.Repositories.NHibernate</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="ConfOrm">
+      <HintPath>..\packages\ConfOrm.1.0.1.5\lib\Net35\ConfOrm.dll</HintPath>
+    </Reference>
+    <Reference Include="ConfOrm.Shop">
+      <HintPath>..\packages\ConfOrm.1.0.1.5\lib\Net35\ConfOrm.Shop.dll</HintPath>
+    </Reference>
+    <Reference Include="Iesi.Collections">
+      <HintPath>..\packages\Iesi.Collections.3.1.0.4000\lib\Net35\Iesi.Collections.dll</HintPath>
+    </Reference>
+    <Reference Include="NHibernate">
+      <HintPath>..\packages\NHibernate.3.1.0.4000\lib\Net35\NHibernate.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="EventoRepository.cs" />
+    <Compile Include="NhHelper.cs" />
+    <Compile Include="PonenteRepository.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="RepositoryBase.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Agendas.Domain\Agendas.Domain.csproj">
+      <Project>{A14907DF-02E4-4FA7-BE27-4292AF50AA22}</Project>
+      <Name>Agendas.Domain</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Repositories.NHibernate/EventoRepository.cs	Tue May 17 14:02:25 2011 -0300
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using AltNetHispano.Agendas.Domain;
+using AltNetHispano.Agendas.Domain.Repositories;
+using NHibernate;
+
+namespace AltNetHispano.Agendas.Repositories.NHibernate
+{
+	public class EventoRepository : RepositoryBase<Evento>, IEventoRepository
+	{
+		public EventoRepository(ISessionFactory sessionFactory) : base(sessionFactory)
+		{
+		}
+
+		public void Delete(Evento evento)
+		{
+			Session.Delete(evento);
+		}
+
+		public Evento Get(Guid vanId)
+		{
+			return Session.Get<Evento>(vanId);
+		}
+
+		public IList<Evento> GetEventosConFecha()
+		{
+			return Session.QueryOver<Evento>().Where(e => e.Fecha != null).List();
+		}
+
+		public IList<Evento> GetEventosSinFecha()
+		{
+			return Session.QueryOver<Evento>().Where(e => e.Fecha == null).List();
+		}
+
+		public Evento GetPropuestaByTitulo(string titulo)
+		{
+			return Session.QueryOver<Evento>().Where(e => e.Titulo==titulo).SingleOrDefault();
+		}
+
+		public void Update(Evento evento)
+		{
+			//No es necesario implementarlo
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Repositories.NHibernate/NhHelper.cs	Tue May 17 14:02:25 2011 -0300
@@ -0,0 +1,46 @@
+using AltNetHispano.Agendas.Domain;
+using ConfOrm;
+using ConfOrm.NH;
+using NHibernate;
+using NHibernate.Cfg;
+
+namespace AltNetHispano.Agendas.Repositories.NHibernate
+{
+	public static class NhHelper
+	{
+		private static ISessionFactory _sessionfactory;
+		private static Configuration _cfg;
+
+		public static Configuration GetConfiguration()
+		{
+			if (_cfg == null)
+			{
+				var orm = new ObjectRelationalMapper();
+				orm.TablePerClass<Evento>();
+				orm.TablePerClass<Ponente>();
+
+				orm.Cascade<Evento, Ponente>(Cascade.None);
+				orm.Cascade<Ponente, Evento>(Cascade.None);
+
+				var mapper = new Mapper(orm);
+
+				var mapping = mapper.CompileMappingFor(typeof(Evento).Assembly.GetTypes());
+				
+				_cfg = new Configuration();
+				_cfg.Configure();
+				_cfg.AddDeserializedMapping(mapping, null);
+			}
+			return _cfg;
+		}
+
+		public static ISessionFactory GetSessionFactory()
+		{
+			if (_sessionfactory == null)
+			{
+				var cfg = GetConfiguration();
+				_sessionfactory=cfg.BuildSessionFactory();
+			}
+			return _sessionfactory;
+		}
+	}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Repositories.NHibernate/PonenteRepository.cs	Tue May 17 14:02:25 2011 -0300
@@ -0,0 +1,24 @@
+using System.Collections.Generic;
+using AltNetHispano.Agendas.Domain;
+using AltNetHispano.Agendas.Domain.Repositories;
+using NHibernate;
+
+namespace AltNetHispano.Agendas.Repositories.NHibernate
+{
+	public class PonenteRepository : RepositoryBase<Ponente>, IPonenteRepository
+	{
+		public PonenteRepository(ISessionFactory sessionFactory) : base(sessionFactory)
+		{
+		}
+
+		public IList<Ponente> GetAll()
+		{
+			return Session.QueryOver<Ponente>().List();
+		}
+
+		public Ponente GetByNombre(string ponenteNombre)
+		{
+			return Session.QueryOver<Ponente>().Where(p => p.Nombre == ponenteNombre).SingleOrDefault();
+		}
+	}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Repositories.NHibernate/Properties/AssemblyInfo.cs	Tue May 17 14:02:25 2011 -0300
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Agendas.Repositories.NHibernate")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("Agendas.Repositories.NHibernate")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("193668d1-ff19-408b-ba46-091f60a2f349")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Repositories.NHibernate/RepositoryBase.cs	Tue May 17 14:02:25 2011 -0300
@@ -0,0 +1,21 @@
+using NHibernate;
+
+namespace AltNetHispano.Agendas.Repositories.NHibernate
+{
+	public class RepositoryBase<T>
+	{
+		private readonly ISessionFactory _sessionFactory;
+
+		public RepositoryBase(ISessionFactory sessionFactory)
+		{
+			_sessionFactory = sessionFactory;
+		}
+
+		protected ISession Session { get { return _sessionFactory.GetCurrentSession(); } }
+
+		public void Save(T obj)
+		{
+			Session.Save(obj);
+		}
+	}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Repositories.NHibernate/packages.config	Tue May 17 14:02:25 2011 -0300
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Iesi.Collections" version="3.1.0.4000" />
+  <package id="NHibernate" version="3.1.0.4000" />
+  <package id="ConfOrm" version="1.0.1.5" />
+</packages>
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Tests/Agendas.Tests.csproj	Tue May 17 01:55:19 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Tests/Agendas.Tests.csproj	Tue May 17 14:02:25 2011 -0300
@@ -31,9 +31,27 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Castle.Core">
+      <HintPath>..\packages\Castle.Core.2.5.2\lib\NET35\Castle.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="ConfOrm, Version=1.0.1.5, Culture=neutral, PublicKeyToken=ed8affdf01cbe4cf, processorArchitecture=MSIL">
+      <HintPath>..\packages\ConfOrm.1.0.1.5\lib\Net35\ConfOrm.dll</HintPath>
+    </Reference>
+    <Reference Include="ConfOrm.Shop">
+      <HintPath>..\packages\ConfOrm.1.0.1.5\lib\Net35\ConfOrm.Shop.dll</HintPath>
+    </Reference>
+    <Reference Include="Iesi.Collections">
+      <HintPath>..\packages\Iesi.Collections.3.1.0.4000\lib\Net35\Iesi.Collections.dll</HintPath>
+    </Reference>
     <Reference Include="Moq">
       <HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
     </Reference>
+    <Reference Include="NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
+      <HintPath>..\packages\NHibernate.3.1.0.4000\lib\Net35\NHibernate.dll</HintPath>
+    </Reference>
+    <Reference Include="NHibernate.ByteCode.Castle">
+      <HintPath>..\packages\NHibernate.Castle.3.1.0.4000\lib\Net35\NHibernate.ByteCode.Castle.dll</HintPath>
+    </Reference>
     <Reference Include="nunit.framework">
       <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
     </Reference>
@@ -53,6 +71,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Cruds\EventoCrud.cs" />
+    <Compile Include="Cruds\EventoCrudNhTests.cs" />
     <Compile Include="PonentesTests.cs" />
     <Compile Include="PropuestasTests.cs" />
     <Compile Include="Cruds\EventoTests.cs" />
@@ -74,10 +93,20 @@
       <Project>{28C5EBFB-EE69-4765-A880-D4DE0BC89F48}</Project>
       <Name>Agendas.Repositories.Memory</Name>
     </ProjectReference>
+    <ProjectReference Include="..\Agendas.Repositories.NHibernate\Agendas.Repositories.NHibernate.csproj">
+      <Project>{0973DF44-3B90-4D2A-B579-C64C93B6C853}</Project>
+      <Name>Agendas.Repositories.NHibernate</Name>
+    </ProjectReference>
   </ItemGroup>
   <ItemGroup>
+    <None Include="App.config" />
     <None Include="packages.config" />
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="hibernate.cfg.xml">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Tests/App.config	Tue May 17 14:02:25 2011 -0300
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+	<connectionStrings>
+		<add name="AltNetHispano" connectionString="Data Source=.\sqlexpress;Initial Catalog=AltNetHispano_Test;Integrated Security=SSPI"/>
+	</connectionStrings>
+</configuration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Tests/Cruds/EventoCrudNhTests.cs	Tue May 17 14:02:25 2011 -0300
@@ -0,0 +1,88 @@
+using System;
+using AltNetHispano.Agendas.Domain;
+using AltNetHispano.Agendas.Repositories.NHibernate;
+using Moq;
+using NHibernate;
+using NHibernate.Cfg;
+using NHibernate.Context;
+using NHibernate.Tool.hbm2ddl;
+using NUnit.Framework;
+
+namespace AltNetHispano.Agendas.Tests.Cruds
+{
+	[TestFixture]
+	public class EventoCrudNhTests
+	{
+		private EventoCrud _eventoCrud;
+
+		#region SetUp
+
+		[SetUp]
+		public void BorrarRepositorios()
+		{
+			Configuration cfg =NhHelper.GetConfiguration();
+			var schemaExport = new SchemaExport(cfg);
+			schemaExport.Create(false, true);
+		}
+
+		[SetUp]
+		public void SetearUsuario()
+		{
+			var seguridad = new Mock<ISeguridad>();
+			seguridad.Setup(s => s.GetUserName()).Returns("neluz");
+			IdentityContext.Current = seguridad.Object;
+		}
+
+		[SetUp]
+		public void CreateCrud()
+		{
+			ISessionFactory sessionFactory=NhHelper.GetSessionFactory();
+			_eventoCrud = new EventoCrud(() => new EventoRepository(sessionFactory), () => new PonenteRepository(sessionFactory),
+			                             () => new RequestEmulator(sessionFactory));
+		}
+
+		#endregion
+
+		[Test]
+		public void Create()
+		{
+			_eventoCrud.Create();
+		}
+
+		[Test]
+		public void Read()
+		{
+			_eventoCrud.Read();
+		}
+
+		[Test]
+		public void Update()
+		{
+			_eventoCrud.Update();
+		}
+
+		[Test]
+		public void Delete()
+		{
+			_eventoCrud.Delete();
+		}
+
+	}
+
+	public class RequestEmulator : IDisposable
+	{
+		private readonly ISession _session;
+
+		public RequestEmulator(ISessionFactory sessionFactory)
+		{
+			_session = sessionFactory.OpenSession();
+			CurrentSessionContext.Bind(_session);
+		}
+
+		public void Dispose()
+		{
+			_session.Flush();
+			_session.Close();
+		}
+	}
+}
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Tests/Cruds/EventoTests.cs	Tue May 17 01:55:19 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Tests/Cruds/EventoTests.cs	Tue May 17 14:02:25 2011 -0300
@@ -1,4 +1,5 @@
 using System;
+using AltNetHispano.Agendas.Domain;
 using AltNetHispano.Agendas.Repositories.Memory;
 using Moq;
 using NUnit.Framework;
@@ -6,16 +7,34 @@
 namespace AltNetHispano.Agendas.Tests.Cruds
 {
 	[TestFixture]
-	public class EventoCrudTests : TestBase
+	public class EventoCrudMemoryTests
 	{
 		private EventoCrud _eventoCrud;
 
+		#region SetUp
+
+		[SetUp]
+		public void BorrarRepositorios()
+		{
+			EventoRepository.Clear();
+			PonenteRepository.Clear();
+		}
+
+		[SetUp]
+		public void SetearUsuario()
+		{
+			var seguridad = new Mock<ISeguridad>();
+			seguridad.Setup(s => s.GetUserName()).Returns("neluz");
+			IdentityContext.Current = seguridad.Object;
+		}
+
 		[SetUp]
 		public void CreateCrud()
 		{
 			_eventoCrud = new EventoCrud(() => new EventoRepository(), ()=>new PonenteRepository(), () => new Mock<IDisposable>().Object);
+		}
 
-		}
+		#endregion
 
 		[Test]
 		public void Create()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Tests/hibernate.cfg.xml	Tue May 17 14:02:25 2011 -0300
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
+	<session-factory>
+		<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
+		<property name="connection.connection_string_name">AltNetHispano</property>
+		<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
+
+		<property name="current_session_context_class">NHibernate.Context.ThreadStaticSessionContext, NHibernate</property>
+		<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
+	</session-factory>
+</hibernate-configuration>
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Tests/packages.config	Tue May 17 01:55:19 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Tests/packages.config	Tue May 17 14:02:25 2011 -0300
@@ -2,4 +2,9 @@
 <packages>
   <package id="Moq" version="4.0.10827" />
   <package id="NUnit" version="2.5.10.11092" />
+  <package id="Iesi.Collections" version="3.1.0.4000" />
+  <package id="NHibernate" version="3.1.0.4000" />
+  <package id="ConfOrm" version="1.0.1.5" />
+  <package id="Castle.Core" version="2.5.2" />
+  <package id="NHibernate.Castle" version="3.1.0.4000" />
 </packages>
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.sln	Tue May 17 01:55:19 2011 -0300
+++ b/Agendas/trunk/src/Agendas.sln	Tue May 17 14:02:25 2011 -0300
@@ -22,6 +22,8 @@
 		Features.txt = Features.txt
 	EndProjectSection
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agendas.Repositories.NHibernate", "Agendas.Repositories.NHibernate\Agendas.Repositories.NHibernate.csproj", "{0973DF44-3B90-4D2A-B579-C64C93B6C853}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -56,6 +58,10 @@
 		{306DDA8A-49A5-42E5-A639-A9D3D521865F}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{306DDA8A-49A5-42E5-A639-A9D3D521865F}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{306DDA8A-49A5-42E5-A639-A9D3D521865F}.Release|Any CPU.Build.0 = Release|Any CPU
+		{0973DF44-3B90-4D2A-B579-C64C93B6C853}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{0973DF44-3B90-4D2A-B579-C64C93B6C853}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{0973DF44-3B90-4D2A-B579-C64C93B6C853}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{0973DF44-3B90-4D2A-B579-C64C93B6C853}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
--- a/Agendas/trunk/src/install packages.bat	Tue May 17 01:55:19 2011 -0300
+++ b/Agendas/trunk/src/install packages.bat	Tue May 17 14:02:25 2011 -0300
@@ -1,3 +1,4 @@
 ..\tools\nuget i Agendas.Tests\packages.config -o packages
+..\tools\nuget i Agendas.Repositories.NHibernate\packages.config -o packages
 
 PAUSE
\ No newline at end of file