public async void ReadQueryStats() { var ctrl = new StatsController(); //Assign var expected = await ctrl.Get(); var count = expected.ToList(); //Assert Assert.NotNull(expected); }
public void Get_ReturnsStatsFromProvider() { var expectedTotal = 5; var expectedAverage = 10; _mockStatsProvider.Setup(sp => sp.GetJobCount()).Returns(expectedTotal); _mockStatsProvider.Setup(sp => sp.GetAverageProcessTimeInMilliseconds()).Returns(expectedAverage); var result = _classUnderTest.Get(); Assert.That(result.Value, Has.Property(nameof(StatsResponse.Total)).EqualTo(expectedTotal)); Assert.That(result.Value, Has.Property(nameof(StatsResponse.Average)).EqualTo(expectedAverage)); }
public void GetWithoutData() { StatsController controller = new StatsController(statServ); MutantController controllerM = new MutantController(mutantServ); controllerM.Delete(); Stats nulas = controller.Get(); Assert.AreEqual(0, nulas.count_human_dna); Assert.AreEqual(0, nulas.count_mutant_dna); Assert.AreEqual(0.0m, nulas.ratio); }
public void ShouldConfigureAndReturnResponseProperly() { Mock <IDNAAnalyzerService> dnaAnalyzerService = new Mock <IDNAAnalyzerService>(); ExpandoObject obj = new ExpandoObject(); var objTask = Task.FromResult(obj); dnaAnalyzerService.Setup(m => m.GetMutantsStats()).Returns(objTask); StatsController controller = new StatsController(dnaAnalyzerService.Object); controller.Request = new HttpRequestMessage(); controller.Request.SetConfiguration(new HttpConfiguration()); var responseMessage = controller.Get(); Assert.AreEqual(responseMessage.Result.StatusCode, System.Net.HttpStatusCode.OK); ExpandoObject outObj; Assert.IsTrue(responseMessage.Result.TryGetContentValue(out outObj)); Assert.AreEqual(outObj, obj); }
public void Get() { //ARRANGE var summary = new DnaSummary { CountHumanDna = 4, CountMutantDna = 2 }; var ratio = Math.Round((decimal)summary.CountMutantDna / summary.CountHumanDna); var mockDnaRepository = _autoMoqer.GetMock <IDnaRepository>(); mockDnaRepository.Setup(x => x.GetSummary()) .Returns(Task.FromResult(summary)); //ACT var result = _statsController.Get().Result; //ASSERT Assert.Equal(result.count_human_dna, 4); Assert.Equal(result.count_mutant_dna, 2); Assert.Equal(result.ratio, ratio); }
public void StatsControllerGet() { var results = _ctrl.Get(); Assert.IsNotNull(results); }
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); }