public void GetClusterEstimatorResult_Failure_InvalidWebServiceId() { const string webServiceId = null; var estimatorController = new EstimatorController(_loadTestDataManager.Object, _apdexScoreEstimator.Object, _clusterEstimator.Object, _fuzzyLogicEstimator.Object, _statisticalEstimator.Object); var result = estimatorController.GetClusterEstimatorResult(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_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.GetClusterEstimatorResult(webServiceId); Assert.IsType <BadRequestObjectResult>(result); }
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); }