public void Comprobar_Que_El_Evento_Se_Lanza_Por_Cada_Senador() { //ARRANGE Dictionary <string, Votacion.EVoto> diccionario; Votacion votacion; int contador = 0; //INITIALIZE diccionario = new Dictionary <string, Votacion.EVoto>(); diccionario.Add("s1", Votacion.EVoto.Afirmativo); diccionario.Add("s2", Votacion.EVoto.Negativo); diccionario.Add("s3", Votacion.EVoto.Abstencion); votacion = new Votacion("Ley123", diccionario); //ACT votacion.EventoVotoEfectuado += MiContador; votacion.Simular(); void MiContador(string senador, EVoto voto) { contador++; } //ASSERT Assert.AreEqual(3, contador); }
public void TestSenadoresII() { //Arrange Dictionary <string, Votacion.EVoto> diccionarioPrueba = new Dictionary <string, Votacion.EVoto>(); Votacion votacionPrueba; int contador = 0; //Act diccionarioPrueba.Add("Senador1", Votacion.EVoto.Abstencion); diccionarioPrueba.Add("Senador2", Votacion.EVoto.Negativo); diccionarioPrueba.Add("Senador3", Votacion.EVoto.Afirmativo); diccionarioPrueba.Add("Senador4", Votacion.EVoto.Afirmativo); votacionPrueba = new Votacion("Ley 25.125", diccionarioPrueba); votacionPrueba.EventoVotoEfectuado += MetodoContador; votacionPrueba.Simular(); void MetodoContador(string senador, Votacion.EVoto voto) { contador++; } //Assert Assert.AreEqual(4, contador); }
public void TestEventoVotacion_SeLanzaTantasVecesComoSenadores() { Dictionary<string, Votacion.EVoto> senadores = new Dictionary<string, Votacion.EVoto>(); senadores.Add("1", Votacion.EVoto.Esperando); senadores.Add("2", Votacion.EVoto.Esperando); Votacion votacion = new Votacion("Ley", senadores); votacion.EventoVotoEfectuado += ManejadorContador; votacion.Simular(); Assert.AreEqual(2, UnitTest1.contadorEvento); }
public void EventoVotacion() { System.Collections.Generic.Dictionary <string, Votacion.EVoto> senadores = new System.Collections.Generic.Dictionary <string, Votacion.EVoto>(); senadores.Add("0", Votacion.EVoto.Abstencion); senadores.Add("1", Votacion.EVoto.Abstencion); senadores.Add("2", Votacion.EVoto.Abstencion); senadores.Add("3", Votacion.EVoto.Abstencion); Votacion v = new Votacion("Nombre", senadores); v.EventoVotoEfectuado += Manejador; v.Simular(); Assert.IsTrue(v.ContadoAfirmativo + v.ContadorAbstencion + v.ContadorNegativo == 4); }
public void CantidadEventos() { Dictionary <string, Votacion.EVoto> senadores = new Dictionary <string, Votacion.EVoto>(); senadores.Add("1", Votacion.EVoto.Abstencion); senadores.Add("2", Votacion.EVoto.Afirmativo); Votacion votacion = new Votacion("TestUnitario", senadores); votacion.EventoVotoEfectuado += new Voto(Contador); votacion.Simular(); Assert.AreEqual(cont, senadores.Count); }
public void TestCompruevaSenadoresLasVecesNecesarias() { Dictionary <string, Votacion.EVoto> senadores = new Dictionary <string, Votacion.EVoto> { { "1", Votacion.EVoto.Esperando }, { "2", Votacion.EVoto.Esperando } }; Votacion votacion = new Votacion("Ley", senadores); votacion.EventoVotoEfectuado += ManejadorContador; votacion.Simular(); Assert.AreEqual(2, contadorEvento); }
public void TestMethod2() { System.Collections.Generic.Dictionary <string, Votacion.EVoto> senadores = new System.Collections.Generic.Dictionary <string, Votacion.EVoto>() { { "1", Votacion.EVoto.Abstencion }, { "2", Votacion.EVoto.Afirmativo } }; Votacion votacion = new Votacion("Ley", senadores); votacion.EventoVotoEfectuado += UnitTest1_evento; votacion.Simular(); Assert.AreEqual(2, contador); }
public void TestMethod2() { System.Collections.Generic.Dictionary <string, Votacion.EVoto> senadores; senadores = new System.Collections.Generic.Dictionary <string, Votacion.EVoto>(); senadores.Add("NICOLAS", Votacion.EVoto.Negativo); senadores.Add("NICOLAO", Votacion.EVoto.Negativo); senadores.Add("Giuliano", Votacion.EVoto.Afirmativo); Votacion v = new Votacion("nombre", senadores); //agrego al evento el contador para ver cuantas veces v.EventoVotoEfectuado += Contador; v.Simular(); //si la cantidad de veces que usa el evento es igual a los senadores Assert.AreEqual(senadores.Count, contador); }
public void cantidadDeEventos() { // arrange Dictionary <string, Votacion.EVoto> senadores = new Dictionary <string, Votacion.EVoto>(); senadores.Add("Senador 1", Votacion.EVoto.Afirmativo); senadores.Add("Senador 2", Votacion.EVoto.Negativo); Votacion votacion = new Votacion("Ley 1", senadores); this.cantidadInvocaciones = 2; short expected = 0; votacion.EventoVotoEfectuado += TestEvento; // act votacion.Simular(); // assert es manejado en el ExpectedException Assert.AreEqual(expected, this.cantidadInvocaciones); }
public void TestInvocacionDelEvento() { Dictionary <string, Votacion.EVoto> senadores = new Dictionary <string, Votacion.EVoto>(); senadores.Add("1", Votacion.EVoto.Afirmativo); senadores.Add("2", Votacion.EVoto.Abstencion); senadores.Add("3", Votacion.EVoto.Negativo); senadores.Add("4", Votacion.EVoto.Afirmativo); Votacion votacion = new Votacion("Ley para los Juan Carlos", senadores); votacion.EventoVotoEfectuado += Manejador; votacion.Simular(); Assert.IsTrue(votacion.ContadorAfirmativo == 2); Assert.IsTrue(votacion.ContadorAbstencion == 1); Assert.IsTrue(votacion.ContadorNegativo == 1); }
private void btnSimular_Click(object sender, EventArgs e) { // Creo una nueva votación votacion = new Votacion(txtLeyNombre.Text, this.participantes); // Mostrar Quorum lblEsperando.Text = this.participantes.Count.ToString(); // Reseteo de la votación foreach (PictureBox p in this.graficos) { p.BackColor = Color.White; } lblAfirmativo.Text = "0"; lblNegativo.Text = "0"; lblAbstenciones.Text = "0"; // EVENTO votacion.EventoVotoEfectuado += ManejadorVoto; // THREAD Thread t = new Thread(votacion.Simular()); t.Start(); }
public void LanzamientoDeEvento_Votacion() { //Arrange Dictionary <string, Votacion.EVoto> participantes = new Dictionary <string, Votacion.EVoto>(); participantes.Add("1", Votacion.EVoto.Abstencion); participantes.Add("2", Votacion.EVoto.Afirmativo); participantes.Add("3", Votacion.EVoto.Negativo); participantes.Add("4", Votacion.EVoto.Abstencion); int suma = 0; Votacion votos = new Votacion("ley", participantes); votos.EventoVotoEfectuado += ManejadorVotos; //Act votos.Simular(); suma = votos.ContadorAbstencion + votos.ContadorAfirmativo + votos.ContadorNegativo; //Assert //Assert.AreEqual(suma, count); Assert.IsTrue(count == suma); }