public void Mutant_ReturnsOkResult() { var dnas = new List <string>(); dnas.Add("GAAT"); dnas.Add("GGgt"); dnas.Add("GGgt"); dnas.Add("GAAt"); var request = new myMicroservice.Model.MutantDnaRequest(); request.Dna = dnas; var miresult = _mutantController.Mutant(request); Assert.IsType <OkObjectResult>(miresult); }
public void TestIsHuman() { MutantController controller = new MutantController(mutantServ); controller.Request = new HttpRequestMessage(); controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); PersonDTO persona = new PersonDTO() { dna = new List <string>() { "ATGCGA", "CAGTGC", "TTATTT", "AGACGG", "GCGTCA", "TCACTG" } }; PersonDTO persona2 = new PersonDTO() { dna = new List <string>() { "ATGCGA", "CAGTGC", "TTATTT", "AGACGG", "GCGTCA", "AAAAAA" } }; var resp = controller.Mutant(persona); var resp2 = controller.Mutant(persona2); Assert.AreEqual(HttpStatusCode.Forbidden, resp.StatusCode); Assert.AreEqual(HttpStatusCode.Forbidden, resp2.StatusCode); }
public void InvalidDna() { MutantController controller = new MutantController(mutantServ); string mensaje = null; controller.Request = new HttpRequestMessage(); controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); PersonDTO invalid = new PersonDTO() { dna = new List <string>() { "AtGCGA", "CAGTGC", "TTATGT", "AGAAGG", "CCCCTA", "TCACTG" } }; try { var resp = controller.Mutant(invalid); Assert.AreEqual(HttpStatusCode.BadRequest, resp.StatusCode); } catch (ValidationException ex) { mensaje = ex.Message; } Assert.IsNotNull(mensaje); }
public void GetData() { MutantController controller = new MutantController(mutantServ); controller.Request = new HttpRequestMessage(); controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); controller.Delete(); PersonDTO persona = new PersonDTO() { dna = new List <string>() { "ATGCGA", "CAGTGC", "TTATTT", "AGACGG", "GCGTCA", "TCACTG" } }; PersonDTO mutante = new PersonDTO() { dna = new List <string>() { "ATGCGA", "CAGTGC", "TTATGT", "AGAAGG", "CCCCTA", "TCACTG" } }; PersonDTO mutante2 = new PersonDTO() { dna = new List <string>() { "ATGCGA", "CAGTGG", "TCCCCT", "ATAGGG", "CCTAAA", "TCATTG" } }; controller.Mutant(persona); controller.Mutant(mutante); controller.Mutant(mutante2); StatsController controllerS = new StatsController(statServ); Stats stat = controllerS.Get(); Assert.AreEqual(1, stat.count_human_dna); Assert.AreEqual(2, stat.count_mutant_dna); Assert.AreEqual(2.0m, stat.ratio); }
public void TestIsMutan() { MutantController controller = new MutantController(mutantServ); controller.Request = new HttpRequestMessage(); controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); //ejemplo PersonDTO mutante = new PersonDTO() { dna = new List <string>() { "ATGCGA", "CAGTGC", "TTATGT", "AGAAGG", "CCCCTA", "TCACTG" } }; //dos columnas PersonDTO mutante2Col = new PersonDTO() { dna = new List <string>() { "ATGCGA", "ACGTGC", "ATATGT", "AGAAGG", "GCCCTA", "ACACTG" } }; //dos filas PersonDTO mutante2Row = new PersonDTO() { dna = new List <string>() { "TTTTGA", "ACGTTC", "ATATGT", "AGAAGG", "GCCCCC", "ACACTG" } }; //2 diagonales PersonDTO mutante2Diag = new PersonDTO() { dna = new List <string>() { "TATTGA", "ACGTTC", "ATATGT", "AGTAGG", "GCCTAC", "ACACTA" } }; var resp = controller.Mutant(mutante); var resp2col = controller.Mutant(mutante2Col); var resp2row = controller.Mutant(mutante2Row); var resp2diag = controller.Mutant(mutante2Diag); Assert.AreEqual(HttpStatusCode.OK, resp.StatusCode); Assert.AreEqual(HttpStatusCode.OK, resp2col.StatusCode); Assert.AreEqual(HttpStatusCode.OK, resp2row.StatusCode); Assert.AreEqual(HttpStatusCode.OK, resp2diag.StatusCode); }