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); }
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); }
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); }
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); }
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); }
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)); }