public void GetStatisticalEstimatorResult_Success() { const string webServiceId = "first"; const bool byRow = false; const bool fromFile = false; List <StatisticalEstimation> expectedResult = new List <StatisticalEstimation>() { new StatisticalEstimation() { MetricName = "test", Min = 0, Max = 50, Median = 25, Mean = 25, Variance = 0, LowerQuartile = 15, UpperQuartile = 35 } }; _metricsDataManager.Setup(metricsDataManager => metricsDataManager.GetMetricsData(webServiceId, fromFile, byRow)); _statisticalEstimator.Setup(statisticalEstimator => statisticalEstimator.FindStatisticalEstimatorResult()).Returns(expectedResult); var estimatorController = new EstimatorController(_loadTestDataManager.Object, _apdexScoreEstimator.Object, _clusterEstimator.Object, _fuzzyLogicEstimator.Object, _statisticalEstimator.Object); var actualResult = estimatorController.GetStatisticalEstimatorResult(webServiceId); var okResult = Assert.IsType <OkObjectResult>(actualResult); var returnValue = Assert.IsType <List <StatisticalEstimation> >(okResult.Value); Assert.Equal(expectedResult, returnValue); }
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 void GetStatisticalEstimatorResult_Failure_InvalidWebServiceId() { const string webServiceId = null; var estimatorController = new EstimatorController(_loadTestDataManager.Object, _apdexScoreEstimator.Object, _clusterEstimator.Object, _fuzzyLogicEstimator.Object, _statisticalEstimator.Object); var result = estimatorController.GetStatisticalEstimatorResult(webServiceId); Assert.IsType <BadRequestObjectResult>(result); }
public void GetFuzzyLogicEstimatorResult_Failure_MissingWebServiceId() { const string webServiceId = "first"; var estimatorController = new EstimatorController(_loadTestDataManager.Object, _apdexScoreEstimator.Object, _clusterEstimator.Object, _fuzzyLogicEstimator.Object, _statisticalEstimator.Object); estimatorController.ModelState.AddModelError("webServiceId", "missing webServiceId"); var result = estimatorController.GetFuzzyLogicEstimatorResult(webServiceId); Assert.IsType <BadRequestObjectResult>(result); }
public void GetClusterEstimatorResult_Failure_ThrowsException() { const string webServiceId = "first"; _clusterEstimator.As <IMetricsData>() .Setup(metricsData => metricsData.MetricsData) .Throws(new Exception()); var estimatorController = new EstimatorController(_loadTestDataManager.Object, _apdexScoreEstimator.Object, _clusterEstimator.Object, _fuzzyLogicEstimator.Object, _statisticalEstimator.Object); Assert.Throws <Exception>(() => estimatorController.GetClusterEstimatorResult(webServiceId)); }
public void GetClusterEstimatorResult_MoreThanOneMetric_Success() { const string webServiceId = "first"; const bool byRow = false; const bool fromFile = true; const double densestClusterDensity = 0.03; const double densestClusterCenterPotential = 0.90; const double densestClusterSpread = 0.95; List <double> densestClusterCenter = new List <double>() { 0.8, 34.5, 0.32 }; List <string[]> metrics = new List <string[]>() { new string[] { "15:00:10", "15:00:15", "30.5", "0" } }; var expectedResult = new List <ClusterEstimation>() { new ClusterEstimation() { Potential = densestClusterCenterPotential, Density = densestClusterDensity, Center = densestClusterCenter, Spread = densestClusterSpread } }; _metricsDataManager.Setup(metricsDataManager => metricsDataManager.GetMetricsData(webServiceId, fromFile, byRow)); _clusterEstimator.Setup(clusterEstimator => clusterEstimator.FindClusterEstimatorResult()).Returns(expectedResult); _clusterEstimator.As <IMetricsData>().Setup(metricsData => metricsData.MetricsData).Returns(metrics); var estimatorController = new EstimatorController(_loadTestDataManager.Object, _apdexScoreEstimator.Object, _clusterEstimator.Object, _fuzzyLogicEstimator.Object, _statisticalEstimator.Object); var actualResult = estimatorController.GetClusterEstimatorResult(webServiceId); var okResult = Assert.IsType <OkObjectResult>(actualResult); var returnValue = Assert.IsType <List <ClusterEstimation> > (okResult.Value); Assert.Equal(expectedResult, returnValue); }
public void GetStatisticalEstimatorResult_Failure_ThrowsException() { const string webServiceId = "first"; const bool byRow = false; const bool fromFile = false; _metricsDataManager.Setup(metricsDataManager => metricsDataManager.GetMetricsData(webServiceId, fromFile, byRow)); _statisticalEstimator .Setup(statisticalEstimator => statisticalEstimator.FindStatisticalEstimatorResult()) .Throws(new Exception()); var estimatorController = new EstimatorController(_loadTestDataManager.Object, _apdexScoreEstimator.Object, _clusterEstimator.Object, _fuzzyLogicEstimator.Object, _statisticalEstimator.Object); Assert.Throws <Exception>(() => estimatorController.GetStatisticalEstimatorResult(webServiceId)); }
public void GetFuzzyLogicEstimatorResult_Success() { const string webServiceId = "first"; const bool byRow = false; const bool fromFile = false; IList <double> expectedResult = new List <double>() { 0.4565, 0.2345 }; _metricsDataManager.Setup(metricsDataManager => metricsDataManager.GetMetricsData(webServiceId, fromFile, byRow)); _fuzzyLogicEstimator.Setup(fuzzyLogicEstimator => fuzzyLogicEstimator.GetAggregatedQualityMembershipFunction()); _fuzzyLogicEstimator.Setup(fuzzyLogicEstimator => fuzzyLogicEstimator.AggregatedQualityMembershipFunction).Returns(expectedResult); var estimatorController = new EstimatorController(_loadTestDataManager.Object, _apdexScoreEstimator.Object, _clusterEstimator.Object, _fuzzyLogicEstimator.Object, _statisticalEstimator.Object); var actualResult = estimatorController.GetFuzzyLogicEstimatorResult(webServiceId); var okResult = Assert.IsType <OkObjectResult>(actualResult); var returnValue = Assert.IsType <List <double> >(okResult.Value); Assert.Equal(expectedResult, returnValue); }