public void GetApdexScoreResult_Success() { const string webServiceId = "first"; const double apdexScoreLimit = 0.05; const bool byRow = false; const bool fromFile = true; ApdexScoreEstimatorResult expectedResult = new ApdexScoreEstimatorResult() { ApdexScoreEstimations = new List <ApdexScoreEstimation>() { new ApdexScoreEstimation() { IntervalStartTime = "15:04:41", IntervalEndTime = "15:04:46", ApdexScore = 0.95 } }, AverageApdexScoreEstimation = 0.95, ApdexScoreEstimationRating = "Excellent", InitialApdexScoreLimit = 0.545 }; _metricsDataManager.Setup(metricsDataManager => metricsDataManager.GetMetricsData(webServiceId, fromFile, byRow)); _apdexScoreEstimator.Setup(apdexScoreEstimator => apdexScoreEstimator.FindApdexScoreEstimatorResult(apdexScoreLimit, fromFile, webServiceId)) .Returns(expectedResult); var estimatorController = new EstimatorController(_loadTestDataManager.Object, _apdexScoreEstimator.Object, _clusterEstimator.Object, _fuzzyLogicEstimator.Object, _statisticalEstimator.Object); var actualResult = estimatorController.GetApdexScoreResult(apdexScoreLimit, webServiceId); var okResult = Assert.IsType <OkObjectResult>(actualResult); var returnValue = Assert.IsType <ApdexScoreEstimatorResult>(okResult.Value); Assert.Equal(expectedResult, returnValue); }
public ApdexScoreEstimatorResult FindApdexScoreEstimatorResult(double?apdexScoreLimit, bool fromFile, string webServiceId) { var initialApdexScoreLimit = FindInitialApdexScoreLimit(); if (!apdexScoreLimit.HasValue) { apdexScoreLimit = initialApdexScoreLimit; } var apdexScoreEstimations = FindApdexScoreEstimations(apdexScoreLimit, fromFile, webServiceId); var averageApdexScore = FindAverageApdexScoreEstimation(apdexScoreEstimations); var apdexScoreEstimationRating = FindApdexScoreEstimationRating(averageApdexScore); var apdexScoreEstimatorResult = new ApdexScoreEstimatorResult() { ApdexScoreEstimations = apdexScoreEstimations, AverageApdexScoreEstimation = averageApdexScore, ApdexScoreEstimationRating = apdexScoreEstimationRating, InitialApdexScoreLimit = initialApdexScoreLimit }; return(apdexScoreEstimatorResult); }
public void FindApdexScoreEstimatorResult_FromFileAndPredefinedLimit_Success() { const string webServiceId = "first"; const bool byRow = false; const bool fromFile = true; const string filePath = ""; const double apdexScoreLimit = 0.05; ApdexScoreEstimatorResult expectedResult = new ApdexScoreEstimatorResult() { ApdexScoreEstimations = new List <ApdexScoreEstimation>() { new ApdexScoreEstimation() { IntervalStartTime = "15:55:38", IntervalEndTime = "15:55:43", ApdexScore = 0 }, new ApdexScoreEstimation() { IntervalStartTime = "15:55:43", IntervalEndTime = "15:55:48", ApdexScore = 0 }, new ApdexScoreEstimation() { IntervalStartTime = "15:55:48", IntervalEndTime = "15:55:53", ApdexScore = 0 }, new ApdexScoreEstimation() { IntervalStartTime = "15:55:53", IntervalEndTime = "15:55:58", ApdexScore = 0 }, new ApdexScoreEstimation() { IntervalStartTime = "15:55:58", IntervalEndTime = "15:56:03", ApdexScore = 0 } }, AverageApdexScoreEstimation = 0, ApdexScoreEstimationRating = "Unacceptable", InitialApdexScoreLimit = 0.7731667 }; _loadTestDataManager .Setup(testDataManager => testDataManager.ReadTestData(webServiceId, fromFile, filePath)) .Returns(_metricsData.ToString()); _loadTestDataPreprocessor .Setup(loadTestDataPreprocessor => loadTestDataPreprocessor.PreprocessMetricsData(_metricsData.ToString(), webServiceId, byRow, fromFile, true)) .Returns(_metricsData); var apdexScoreEstimator = new ApdexScoreEstimator(_loadTestDataManager.Object, _loadTestDataPreprocessor.Object); apdexScoreEstimator.GetMetricsData(webServiceId, fromFile, byRow); var result = apdexScoreEstimator.FindApdexScoreEstimatorResult(apdexScoreLimit, fromFile, webServiceId); Assert.IsType <ApdexScoreEstimatorResult>(result); Assert.Equal <ApdexScoreEstimatorResult>(expectedResult, result); }