Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs @ 147:5a1f7233aa5a
Agregando algunos tests
author | Nelo@Guinea.neluz.int |
---|---|
date | Mon, 01 Aug 2011 17:34:35 -0300 |
parents | 2dbb15f4510f |
children | f17252543cbf |
comparison
equal
deleted
inserted
replaced
146:3ca9fb66d397 | 147:5a1f7233aa5a |
---|---|
58 Assert.AreEqual(1, persona.Cuentas.Count()); | 58 Assert.AreEqual(1, persona.Cuentas.Count()); |
59 Assert.IsTrue(personaService.CreateIfNotExist(IdentityProviderEnum.Twitter, "marianopauselli", "Mariano Pauselli")); | 59 Assert.IsTrue(personaService.CreateIfNotExist(IdentityProviderEnum.Twitter, "marianopauselli", "Mariano Pauselli")); |
60 Assert.AreEqual(1, persona.Cuentas.Count()); | 60 Assert.AreEqual(1, persona.Cuentas.Count()); |
61 } | 61 } |
62 | 62 |
63 [Test] | |
64 public void Agregar_y_modificar_persona() | |
65 { | |
66 var personaRepository = DefaultPersonaRepository; | |
67 | |
68 var personaService = new PersonaService(personaRepository); | |
69 var r = personaService.Add("Mariano Pauselli", "marianopauselli", string.Empty); | |
70 Assert.IsTrue(r.Succeful); | |
71 | |
72 var todas = personaService.GetAll(); | |
73 Assert.AreEqual(2, todas.Count()); | |
74 | |
75 var p1 = todas.SingleOrDefault(p => p.Nombre == "Mariano Pauselli"); | |
76 Assert.IsNotNull(p1); | |
77 | |
78 var personaId = p1.Id; | |
79 var p2 = personaService.GetById(personaId); | |
80 | |
81 Assert.AreEqual(p1, p2); | |
82 Assert.AreSame(p1, p2); | |
83 | |
84 personaService.Update(personaId, p1.Nombre, p1.Twitter, "marianopauselli@gmail.com"); | |
85 | |
86 var p3 = personaService.GetById(personaId); | |
87 Assert.IsNotNull(p3); | |
88 Assert.AreEqual("marianopauselli@gmail.com",p3.Mail); | |
89 } | |
90 | |
91 [Test] | |
92 public void Agregar_y_modificar_cuenta() | |
93 { | |
94 var personaRepository = DefaultPersonaRepository; | |
95 | |
96 var p1 = personaRepository.GetByTwitter("nelopauselli"); | |
97 Assert.IsNotNull(p1); | |
98 Assert.AreEqual(1, p1.Cuentas.Count()); | |
99 | |
100 var personaService = new PersonaService(personaRepository); | |
101 | |
102 personaService.AddCuenta(IdentityProviderEnum.Google, "nelopauselli"); | |
103 | |
104 var p2 = personaRepository.GetByTwitter("nelopauselli"); | |
105 Assert.IsNotNull(p2); | |
106 Assert.AreEqual(2, p2.Cuentas.Count()); | |
107 | |
108 var personaId = p2.Id; | |
109 | |
110 personaService.RemoveCuenta(IdentityProviderEnum.Google, "nelopauselli"); | |
111 Assert.AreEqual(1, personaRepository.Get(personaId).Cuentas.Count()); | |
112 | |
113 personaService.RemoveCuenta(IdentityProviderEnum.Twitter, "nelopauselli"); | |
114 Assert.AreEqual(0, personaRepository.Get(personaId).Cuentas.Count()); | |
115 | |
116 } | |
117 | |
63 [Test] | 118 [Test] |
64 public void IdentificacionGoogle() | 119 public void IdentificacionGoogle() |
65 { | 120 { |
66 var builtIn = new Identification(Identification.Map[(int)IdentityProviderEnum.Google] + "nelo"); | 121 var builtIn = new Identification(Identification.Map[(int)IdentityProviderEnum.Google] + "nelo"); |
67 Assert.AreEqual(IdentityProviderEnum.Google, builtIn.IdentityProvider); | 122 Assert.AreEqual(IdentityProviderEnum.Google, builtIn.IdentityProvider); |