view Agendas/trunk/src/Agendas.Tests/TestBase.cs @ 112:0bca45e1e664

Pantalla de Perfil donde se puede asociar la cuenta de twitter al usuario existente
author Nelo@Kenia.neluz.int
date Sat, 11 Jun 2011 01:20:59 -0300
parents db4b1e2cae49
children 7a2eeb9e9bf9
line wrap: on
line source

using AltNetHispano.Agendas.Domain;
using AltNetHispano.Agendas.Domain.Repositories;
using AltNetHispano.Agendas.Domain.Services;
using AltNetHispano.Agendas.Repositories.Memory;
using Moq;
using NUnit.Framework;

namespace AltNetHispano.Agendas.Tests
{
	public class TestBase
	{
		protected static IEventoRepository DefaultEventoRepository
		{
			get { return new EventoRepository(); }
		}

		protected static IPersonaRepository DefaultPersonaRepository
		{
			get { return new PersonaRepository(); }
		}

		[SetUp]
		public void LimpiarEventos()
		{
			EventoRepository.Clear();
		}

		[SetUp]
		public void LimpiarPonentes()
		{
			PersonaRepository.Clear();
			SetCurrentUser("nelopauselli", "Nelo Pauselli");
		}

		protected static void SetCurrentUser(string username, string nombre)
		{
			const IdentityProviderEnum identityProvider = IdentityProviderEnum.Twitter;
			string logonName = null;
			if (username != null)
				logonName = Identification.Map[(int) IdentityProviderEnum.Twitter] + username;

			var seguridad = new Mock<ISeguridad>();
			seguridad.Setup(s => s.GetUserName()).Returns(logonName);
			
			IPersonaRepository personaRepository = new PersonaRepository();
			var service = new PersonaService(personaRepository);
			service.Validate(identityProvider, username, nombre);

			IdentityContext.Init(seguridad.Object, personaRepository);

		}
	}
}