Mercurial > altnet-hispano
changeset 241:a7daa939ef0c
Probando de armar tests de Agendas.Web
author | juanjose.montesdeocaarbos |
---|---|
date | Wed, 05 Oct 2011 07:43:09 -0300 |
parents | 01a9b47185eb |
children | 5cc1681d3789 |
files | Agendas/trunk/src/Agendas.Web.Tests/Agendas.Web.Tests.csproj Agendas/trunk/src/Agendas.Web.Tests/Controllers/EventoControllerTests.cs Agendas/trunk/src/Agendas.Web.Tests/hibernate.cfg.xml Agendas/trunk/src/install packages.bat |
diffstat | 4 files changed, 59 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Web.Tests/Agendas.Web.Tests.csproj Wed Oct 05 07:41:30 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web.Tests/Agendas.Web.Tests.csproj Wed Oct 05 07:43:09 2011 -0300 @@ -31,6 +31,10 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <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" /> <Reference Include="NHibernate.ByteCode.Castle"> <HintPath>..\packages\NHibernate.Castle.3.1.0.4000\lib\Net35\NHibernate.ByteCode.Castle.dll</HintPath> </Reference> @@ -56,15 +60,24 @@ <Project>{A14907DF-02E4-4FA7-BE27-4292AF50AA22}</Project> <Name>Agendas.Domain</Name> </ProjectReference> + <ProjectReference Include="..\Agendas.NHibernate\Agendas.NHibernate.csproj"> + <Project>{9519A43A-9D5E-4BFD-9F88-AFFC53C9973A}</Project> + <Name>Agendas.NHibernate</Name> + </ProjectReference> + <ProjectReference Include="..\Agendas.Repositories.NHibernate\Agendas.Repositories.NHibernate.csproj"> + <Project>{0973DF44-3B90-4D2A-B579-C64C93B6C853}</Project> + <Name>Agendas.Repositories.NHibernate</Name> + </ProjectReference> + <ProjectReference Include="..\Agendas.Repositories.Tests\Agendas.Repositories.Tests.csproj"> + <Project>{BFCD197C-01D5-4645-B0DF-053867E16FDE}</Project> + <Name>Agendas.Repositories.Tests</Name> + </ProjectReference> <ProjectReference Include="..\Agendas.Web\Agendas.Web.csproj"> <Project>{319A8E3D-C61E-455F-A1BF-A6B1B1636BAB}</Project> <Name>Agendas.Web</Name> </ProjectReference> </ItemGroup> <ItemGroup> - <None Include="App_.config"> - <SubType>Designer</SubType> - </None> <Content Include="App.config"> <SubType>Designer</SubType> </Content> @@ -74,6 +87,9 @@ <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </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.
--- a/Agendas/trunk/src/Agendas.Web.Tests/Controllers/EventoControllerTests.cs Wed Oct 05 07:41:30 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web.Tests/Controllers/EventoControllerTests.cs Wed Oct 05 07:43:09 2011 -0300 @@ -2,9 +2,13 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using Agendas.NHibernate; +using Agendas.Repositories.Tests.Infraestructure; using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Repositories.NHibernate; using AltNetHispano.Agendas.Web.Controllers; using AltNetHispano.Agendas.Web.Models; +using Moq; using NUnit.Framework; namespace Agendas.Web.Tests.Controllers @@ -12,33 +16,49 @@ [TestFixture] public class EventoControllerTests { + [SetUp] + public void SetearUsuario() + { + var seguridad = new Mock<ISeguridad>(); + seguridad.Setup(s => s.GetUserName()).Returns("neluz"); + IdentityContext.Init(seguridad.Object, new PersonaRepository(NhHelper.GetSessionFactory())); + + } + [Test] - [Ignore] + //[Ignore] public void Publicar_Evento() { var eventoController = new EventoController(); var eventoNew = new EventoNewModel - { - Duracion = new TimeSpan(0, 0, 0), - Fecha = DateTime.Today.AddDays(5), - Hora = new TimeSpan(18, 0, 0), - Ponente = new Guid(), - TipoEvento = (int)TipoEvento.Van, - Titulo = "Título 1" - }; + { + Duracion = new TimeSpan(0, 0, 0), + Fecha = DateTime.Today.AddDays(5), + Hora = new TimeSpan(18, 0, 0), + //Ponentes = new[] { Guid.NewGuid() }, + TipoEvento = (int)TipoEvento.Van, + Titulo = "Título 1" + }; - var resultNuevo = eventoController.Nuevo(eventoNew); + using (new RequestEmulator(NhHelper.GetSessionFactory())) + { + var resultNuevo = eventoController.Nuevo(eventoNew); + } - //var eventoPublicar = new EventoPublicarModel - // { - // NroOrden = 1, - // Titulo = "Título 1", - // UrlWiki = "http://www.altnethistpano.org/vans/titulo-1.ashx", - // DuracionReal = new TimeSpan() - // }; + var eventoPublicar = new EventoPublicarModel + { + NroOrden = 1, + Titulo = "Título 1", + UrlWiki = "http://www.altnethistpano.org/vans/titulo-1.ashx", + DuracionReal = new TimeSpan(0, 0, 0) + }; - //var resultPublicar = eventoController.Publicar(eventoPublicar); + using (new RequestEmulator(NhHelper.GetSessionFactory())) + { + var resultPublicar = eventoController.Publicar(eventoPublicar); + } } } + }
--- a/Agendas/trunk/src/Agendas.Web.Tests/hibernate.cfg.xml Wed Oct 05 07:41:30 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web.Tests/hibernate.cfg.xml Wed Oct 05 07:43:09 2011 -0300 @@ -5,7 +5,7 @@ <property name="connection.connection_string_name">AltNetHispano</property> <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property> - <property name="current_session_context_class">web</property> + <property name="current_session_context_class">thread_static</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/install packages.bat Wed Oct 05 07:41:30 2011 -0300 +++ b/Agendas/trunk/src/install packages.bat Wed Oct 05 07:43:09 2011 -0300 @@ -7,5 +7,6 @@ ..\tools\nuget i Agendas.Twitter.Tests\packages.config -o packages ..\tools\nuget i Agendas.Google\packages.config -o packages ..\tools\nuget i Agendas.Google.Test\packages.config -o packages +..\tools\nuget i Agendas.Web.Tests\packages.config -o packages PAUSE \ No newline at end of file