Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public void GetApdexScoreResult_Failure_InvalidWebServiceId()
        {
            const string webServiceId    = null;
            const double apdexScoreLimit = 0.05;

            var estimatorController = new EstimatorController(_loadTestDataManager.Object, _apdexScoreEstimator.Object,
                                                              _clusterEstimator.Object, _fuzzyLogicEstimator.Object, _statisticalEstimator.Object);

            var result = estimatorController.GetApdexScoreResult(apdexScoreLimit, webServiceId);

            Assert.IsType <BadRequestObjectResult>(result);
        }
Exemplo n.º 3
0
        public void GetApdexScoreResult_Failure_MissingWebServiceId()
        {
            const string webServiceId    = "first";
            const double apdexScoreLimit = 0.05;

            var estimatorController = new EstimatorController(_loadTestDataManager.Object, _apdexScoreEstimator.Object,
                                                              _clusterEstimator.Object, _fuzzyLogicEstimator.Object, _statisticalEstimator.Object);

            estimatorController.ModelState.AddModelError("webServiceId", "missing webServiceId");

            var result = estimatorController.GetApdexScoreResult(apdexScoreLimit, webServiceId);

            Assert.IsType <BadRequestObjectResult>(result);
        }
Exemplo n.º 4
0
        public void GetApdexScoreResult_Failure_ThrowsException()
        {
            const string webServiceId    = "first";
            const double apdexScoreLimit = 0.05;
            const bool   byRow           = false;
            const bool   fromFile        = true;

            _metricsDataManager.Setup(metricsDataManager => metricsDataManager.GetMetricsData(webServiceId, fromFile, byRow));
            _apdexScoreEstimator.Setup(apdexScoreEstimator => apdexScoreEstimator.FindApdexScoreEstimatorResult(apdexScoreLimit, fromFile, webServiceId))
            .Throws(new Exception());

            var estimatorController = new EstimatorController(_loadTestDataManager.Object, _apdexScoreEstimator.Object,
                                                              _clusterEstimator.Object, _fuzzyLogicEstimator.Object, _statisticalEstimator.Object);

            Assert.Throws <Exception>(() => estimatorController.GetApdexScoreResult(apdexScoreLimit, webServiceId));
        }