示例#1
0
        public void StdDev_Test()
        {
            //Arrange
            double     var      = 50;
            double     expected = 7.07;
            double     actual;
            IBLService bLService = BLServiceFactory.GetBLServiceObj();

            //Act
            actual = bLService.StdDev(var);

            //Assert
            Assert.AreEqual(expected, actual);
        }
示例#2
0
        public void CountWords_Test()
        {
            //Arrange
            string     text     = "hello my name is test";
            int        expected = 5;
            int        actual;
            IBLService bLService = BLServiceFactory.GetBLServiceObj();

            //Act
            actual = bLService.CountWords(text);

            //Assert
            Assert.AreEqual(expected, actual);
        }
示例#3
0
        public void GetTitle_Test()
        {
            //Arrange
            string        strDetails = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><metadata><release-list><release><title>My Song</title></release></release-list></metadata>";
            List <string> expected   = new List <string>();
            List <string> actual     = new List <string>();
            IBLService    bLService  = BLServiceFactory.GetBLServiceObj();

            //Act
            expected.Add("My Song");
            actual = bLService.GetTitles(strDetails);

            //Assert
            Assert.AreEqual(expected.Count, actual.Count);
        }
示例#4
0
        public void CalcAverage_Test()
        {
            //Arrange
            List <int> noOfWords = new List <int>();
            double     expected  = 15;
            double     actual;
            IBLService bLService = BLServiceFactory.GetBLServiceObj();

            //Act
            noOfWords.Add(10);
            noOfWords.Add(20);
            noOfWords.Add(15);
            actual = bLService.CalcAverage(noOfWords);

            //Assert
            Assert.AreEqual(expected, actual);
        }
示例#5
0
        public void Variance_Test()
        {
            //Arrange
            List <int> noOfWords = new List <int>();
            double     avg       = 15;
            double     expected  = 50;
            double     actual;
            IBLService bLService = BLServiceFactory.GetBLServiceObj();

            //Act
            noOfWords.Add(10);
            noOfWords.Add(15);
            noOfWords.Add(20);
            actual = bLService.Variance(noOfWords, avg);

            //Assert
            Assert.AreEqual(expected, actual);
        }
示例#6
0
        public async System.Threading.Tasks.Task <ActionResult> GetDataAsync(Artist model)
        {
            if (ModelState.IsValid)
            {
                var baseAddress  = new Uri(ConfigurationManager.AppSettings["baseAddress"]);
                var baseAddress1 = new Uri(ConfigurationManager.AppSettings["baseAddress1"]);

                IBLService    _blService;
                List <string> singles   = new List <string>();
                List <int>    noOfWords = new List <int>();
                List <Song>   songs     = new List <Song>();

                //Get all releases for selected group/artist
                _blService = BLServiceFactory.GetBLServiceObj();
                HttpClient httpClient1 = new HttpClient();
                httpClient1.BaseAddress = baseAddress1;
                httpClient1.DefaultRequestHeaders.Add("User-Agent", "C# App");
                httpClient1.Timeout = TimeSpan.FromSeconds(30);

                //Get songs for the selected artist
                singles = await GetSingles(model, _blService, singles, httpClient1);

                //call api to get the lyrics of each song
                await GetLyrics(model, baseAddress, _blService, singles, songs);

                noOfWords      = songs.Select(x => x.WordCount).ToList();
                model.Avg      = _blService.CalcAverage(noOfWords);
                model.MinWords = noOfWords.Min();
                model.MaxWords = noOfWords.Max();
                model.Range    = model.MaxWords - model.MinWords;
                model.Var      = _blService.Variance(noOfWords, model.Avg);
                model.StdDev   = _blService.StdDev(model.Var);
                model.Songs    = songs;
            }


            return(View("GetData", model));
        }