Mercurial > altnet-hispano
view Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs @ 100:cc91817a4206
Merge
author | jorge.rowies |
---|---|
date | Sat, 04 Jun 2011 22:46:06 -0300 |
parents | 1eb5a0e531bf |
children | 7a2eeb9e9bf9 |
line wrap: on
line source
using System.Linq; using AltNetHispano.Agendas.Domain; using AltNetHispano.Agendas.Domain.Repositories; using AltNetHispano.Agendas.Domain.Services; using Moq; using NUnit.Framework; namespace AltNetHispano.Agendas.Tests { [TestFixture] public class PersonaServiceTests : TestBase { [Test] public void Crear_nueva_persona() { var personaRepository = new Mock<IPersonaRepository>(); Persona persona=null; personaRepository.Setup(r => r.Save(It.IsAny<Persona>())).Callback<Persona>(p => persona = p); var personaService = new PersonaService(personaRepository.Object); Assert.IsTrue(personaService.Validate(IdentityProviderEnum.Twitter, "nelopauselli", "Nelo Pauselli")); personaRepository.Verify(r=>r.Save(It.IsAny<Persona>()), Times.Once()); Assert.IsNotNull(persona); Assert.AreEqual(1, persona.Cuentas.Count()); Assert.AreEqual("nelopauselli", persona.Twitter); Cuenta cuenta = persona.Cuentas.First(); Assert.AreEqual(IdentityProviderEnum.Twitter, cuenta.IdentityProvider); Assert.AreEqual("nelopauselli", cuenta.LogonName); personaRepository.Setup(r => r.GetCuenta(IdentityProviderEnum.Twitter, "nelopauselli")).Returns(cuenta); Assert.AreEqual(1, persona.Cuentas.Count()); Assert.IsTrue(personaService.Validate(IdentityProviderEnum.Twitter, "nelopauselli", "Nelo Pauselli")); Assert.AreEqual(1, persona.Cuentas.Count()); } [Test] public void IdentificacionBuiltIn() { var builtIn = new Identification(Identification.Map[(int) IdentityProviderEnum.BuiltIn] + "nelo"); Assert.AreEqual(IdentityProviderEnum.BuiltIn, builtIn.IdentityProvider); Assert.AreEqual("nelo", builtIn.LogonName); } [Test] public void IdentificacionTwitter() { var builtIn = new Identification(Identification.Map[(int)IdentityProviderEnum.Twitter] + "nelo"); Assert.AreEqual(IdentityProviderEnum.Twitter, builtIn.IdentityProvider); Assert.AreEqual("nelo", builtIn.LogonName); } } }