Exemplo n.º 1
0
        public void CountWords_WhenSongLyricsIsNull_ShouldReturnZero()
        {
            var song = new Song();

            var result = SongHelper.CountWords(song);

            result.Should().Be(0);
        }
Exemplo n.º 2
0
        public void CountWords_WhenSongIsInstrumental_ShouldWordCount()
        {
            var song = new Song {
                Lyrics = "instrumental"
            };

            var result = SongHelper.CountWords(song);

            result.Should().Be(1);
        }
Exemplo n.º 3
0
        public void CountWords_WhenSongHasLyrics_ShouldWordCount()
        {
            var song = new Song {
                Lyrics = "hello world"
            };

            var result = SongHelper.CountWords(song);

            result.Should().Be(2);
        }
Exemplo n.º 4
0
        public void CountWords_WhenSongLyricsIsEmpty_ShouldReturnZero()
        {
            var song = new Song {
                Lyrics = string.Empty
            };

            var result = SongHelper.CountWords(song);

            result.Should().Be(0);
        }
Exemplo n.º 5
0
        private ArtistSongsStats ExtractStatsFromSongs(IEnumerable <Song> songs)
        {
            if (songs == null || !songs.Any())
            {
                return(new ArtistSongsStats());
            }

            var shortestSongWordCount = songs.Min(x => SongHelper.CountWords(x));
            var shortestSong          = songs.Where(x => SongHelper.CountWords(x) == shortestSongWordCount).FirstOrDefault();

            var longestSongWordCount = songs.Max(x => SongHelper.CountWords(x));
            var longestSong          = songs.Where(x => SongHelper.CountWords(x) == longestSongWordCount).FirstOrDefault();

            return(new ArtistSongsStats
            {
                SongsCount = songs.Count(),
                AverageWordsInSongs = (int)songs.Average(s => SongHelper.CountWords(s)),
                ShortestSongWordCount = shortestSongWordCount,
                LongestSongWordCount = longestSongWordCount,
                ShortestSong = shortestSong.Work.Title,
                LongestSong = longestSong.Work.Title
            });
        }
Exemplo n.º 6
0
        public void CountWords_WhenSongIsNull_ShouldReturnZero()
        {
            var result = SongHelper.CountWords(null);

            result.Should().Be(0);
        }