public override IFeedSettings ToFeedSettings()
        {
            ScoreSaberFeedSettings baseSettings = base.ToFeedSettings() as ScoreSaberFeedSettings ?? new ScoreSaberFeedSettings((int)ScoreSaberFeed);

            baseSettings.MaxSongs   = this.MaxSongs;
            baseSettings.RankedOnly = true;
            return(baseSettings);
        }
Exemple #2
0
        public void Search_NullQuery()
        {
            var settings = new ScoreSaberFeedSettings(ScoreSaberFeedName.Search);
            var feed     = new ScoreSaberFeed(settings);
            var ex       = Assert.ThrowsException <InvalidFeedSettingsException>(() => feed.EnsureValidSettings());

            Console.WriteLine(ex.Message);
            Assert.IsFalse(feed.HasValidSettings);
        }
Exemple #3
0
        public void Search_HasQuery()
        {
            var settings = new ScoreSaberFeedSettings(ScoreSaberFeedName.Search);

            settings.SearchQuery = "test";
            var feed = new ScoreSaberFeed(settings);

            feed.EnsureValidSettings();
            Assert.IsTrue(feed.HasValidSettings);
        }
Exemple #4
0
        public void QuerylessFeeds()
        {
            var querylessFeeds = new ScoreSaberFeedName[] { ScoreSaberFeedName.LatestRanked, ScoreSaberFeedName.TopPlayed, ScoreSaberFeedName.TopRanked, ScoreSaberFeedName.Trending };

            foreach (var feedType in querylessFeeds)
            {
                var settings = new ScoreSaberFeedSettings(feedType);
                var feed     = new ScoreSaberFeed(settings);
                feed.EnsureValidSettings();
                Assert.IsTrue(feed.HasValidSettings);
            }
        }
Exemple #5
0
        public void GetSongsFromFeed_Trending()
        {
            var reader   = new ScoreSaberReader();
            int maxSongs = 100;
            var settings = new ScoreSaberFeedSettings((int)ScoreSaberFeedName.Trending)
            {
                MaxSongs = maxSongs, SongsPerPage = 40, RankedOnly = true
            };
            var songList = reader.GetSongsFromFeed(settings);

            Assert.IsTrue(songList.Count == maxSongs);
            Assert.IsFalse(songList.Songs.Keys.Any(k => string.IsNullOrEmpty(k)));
        }
Exemple #6
0
        public void GetSongsFromFeed_Search()
        {
            var reader   = new ScoreSaberReader();
            int maxSongs = 40;
            var settings = new ScoreSaberFeedSettings((int)ScoreSaberFeedName.Search)
            {
                MaxSongs = maxSongs, SongsPerPage = 40, RankedOnly = true, SearchQuery = "Believer"
            };
            var songList = reader.GetSongsFromFeed(settings);

            Assert.IsTrue(songList.Songs.Values.Any(s => s.Name.ToLower().Contains("believer")));
            Assert.IsFalse(songList.Songs.Keys.Any(k => string.IsNullOrEmpty(k)));
        }
Exemple #7
0
        public void GetSongsFromFeed_TopRanked()
        {
            var reader   = new ScoreSaberReader();
            int maxSongs = 0;
            var settings = new ScoreSaberFeedSettings((int)ScoreSaberFeedName.TopRanked)
            {
                MaxSongs = maxSongs, SongsPerPage = 40, RankedOnly = true
            };
            var songList = reader.GetSongsFromFeed(settings);

            Console.WriteLine($"{songList.Count} songs.");
            Assert.IsTrue(songList.Count >= 367);
            Assert.IsFalse(songList.Songs.Keys.Any(k => string.IsNullOrEmpty(k)));
        }
Exemple #8
0
        public void GetSongsFromFeed_LatestRanked()
        {
            var reader   = new ScoreSaberReader();
            int maxSongs = 50;
            var settings = new ScoreSaberFeedSettings((int)ScoreSaberFeedName.LatestRanked)
            {
                MaxSongs = maxSongs, SongsPerPage = 40, RankedOnly = true
            };
            var result = reader.GetSongsFromFeed(settings);

            Assert.IsTrue(result.Count == maxSongs);
            Assert.IsFalse(result.Songs.Keys.Any(k => string.IsNullOrEmpty(k)));
            Assert.IsTrue(1 <= result.PagesChecked);
        }
Exemple #9
0
        public void CancelledInProgress()
        {
            var reader   = new ScoreSaberReader();
            var cts      = new CancellationTokenSource(500);
            int maxSongs = 50;
            var settings = new ScoreSaberFeedSettings((int)ScoreSaberFeedName.LatestRanked)
            {
                MaxSongs = maxSongs, SongsPerPage = 10, RankedOnly = true
            };
            var result = reader.GetSongsFromFeed(settings, cts.Token);

            Assert.IsFalse(result.Successful);
            Assert.AreEqual(FeedResultError.Cancelled, result.ErrorCode);
            cts.Dispose();
        }
        public override IFeedSettings ToFeedSettings()
        {
            ScoreSaberFeedSettings feedSettings = new ScoreSaberFeedSettings(ScoreSaberFeed);

            if (!IncludeUnstarred || MinStars > 0 || MaxStars > 0)
            {
                feedSettings.Filter = s =>
                {
                    float stars = s.JsonData?.Value <float>("stars") ?? 0;
                    if (stars == 0)
                    {
                        return(IncludeUnstarred);
                    }
                    return(stars > MinStars && (stars < MaxStars || MaxStars == 0));
                };
                feedSettings.StoreRawData = true;
            }
            return(feedSettings);
        }