Esempio n. 1
0
        public void FindClusterEstimatorResult_Success_TwoClusters()
        {
            const string webServiceId   = "first";
            const bool   byRow          = true;
            const bool   fromFile       = true;
            const string filePath       = "";
            var          expectedResult = new List <ClusterEstimation>()
            {
                new ClusterEstimation()
                {
                    Center = new List <double>()
                    {
                        0.008, 8, 0, 1.29132
                    },
                    Density   = 0.48838259233869064,
                    Potential = 2.9956271341667708,
                    Spread    = 0.5
                },
                new ClusterEstimation()
                {
                    Center = new List <double>()
                    {
                        31.994375, 18, 0, 15.43064
                    },
                    Density   = 0.51655634484497237,
                    Potential = 2.7640230334912923,
                    Spread    = 0.5
                }
            };


            _loadTestDataManager
            .Setup(testDataManager => testDataManager.ReadTestData(webServiceId, fromFile, filePath))
            .Returns(_twoClustersMetricsData.ToString());
            _loadTestDataPreprocessor
            .Setup(loadTestDataPreprocessor => loadTestDataPreprocessor.PreprocessMetricsData(_oneClusterMetricsData.ToString(), webServiceId, byRow, fromFile, true))
            .Returns(_twoClustersMetricsData);

            var clusterEstimator = new ClusterEstimator(_loadTestDataManager.Object, _loadTestDataPreprocessor.Object);

            clusterEstimator.GetMetricsData(webServiceId, fromFile, byRow);

            var result = clusterEstimator.FindClusterEstimatorResult();

            Assert.IsType <List <ClusterEstimation> >(result);
            Assert.Equal(expectedResult, result);
        }
Esempio n. 2
0
        public void GetMetricsData_Success_TwoClusters()
        {
            const string webServiceId = "first";
            const bool   byRow        = true;
            const bool   fromFile     = true;
            const string filePath     = "";

            _loadTestDataManager
            .Setup(testDataManager => testDataManager.ReadTestData(webServiceId, fromFile, filePath))
            .Returns(_twoClustersMetricsData.ToString());
            _loadTestDataPreprocessor
            .Setup(loadTestDataPreprocessor => loadTestDataPreprocessor.PreprocessMetricsData(_oneClusterMetricsData.ToString(), webServiceId, byRow, fromFile, true))
            .Returns(_twoClustersMetricsData);

            var clusterEstimator = new ClusterEstimator(_loadTestDataManager.Object, _loadTestDataPreprocessor.Object);

            clusterEstimator.GetMetricsData(webServiceId, fromFile, byRow);
            var result = clusterEstimator.MetricsData;

            Assert.IsType <List <string[]> >(result);
            Assert.Equal(_twoClustersMetricsData, result);
        }
Esempio n. 3
0
        public void FindClusterEstimatorResult_Success_OneCluster()
        {
            const string webServiceId   = "first";
            const bool   byRow          = true;
            const bool   fromFile       = true;
            const string filePath       = "";
            var          expectedResult = new List <ClusterEstimation>()
            {
                new ClusterEstimation()
                {
                    Center = new List <double>()
                    {
                        0.7731667, 1.2, 0, 3.025
                    },
                    Density   = 0.066917659056544315,
                    Potential = 3.5435429288924456,
                    Spread    = 1
                }
            };


            _loadTestDataManager
            .Setup(testDataManager => testDataManager.ReadTestData(webServiceId, fromFile, filePath))
            .Returns(_oneClusterMetricsData.ToString());
            _loadTestDataPreprocessor
            .Setup(loadTestDataPreprocessor => loadTestDataPreprocessor.PreprocessMetricsData(_oneClusterMetricsData.ToString(), webServiceId, byRow, fromFile, true))
            .Returns(_oneClusterMetricsData);

            var clusterEstimator = new ClusterEstimator(_loadTestDataManager.Object, _loadTestDataPreprocessor.Object);

            clusterEstimator.GetMetricsData(webServiceId, fromFile, byRow);

            var result = clusterEstimator.FindClusterEstimatorResult();

            Assert.IsType <List <ClusterEstimation> >(result);
            Assert.Equal(expectedResult, result);
        }