예제 #1
0
        public async Task HandleAsync(QueueEnded args)
        {
            await _logService.LogAppActivityAsync($"Playlist has ended for party with code {args.PartyCode}. Sending to all listeners");

            Party party = await _partyService.GetPartyWithCodeAsync(args.PartyCode);

            if (party.GetListeners().Count < 1)
            {
                await _partyService.EndPartyAsync(args.PartyCode);

                return;
            }

            List <Track> playlistSongs = await _partyService.GenerateNewPlaylist(party, args.SeedTracksUris, args.SeedArtistUris);

            await party.AddNewQueueAsync(playlistSongs);

            await _partyHubContext.Clients.Group(args.PartyCode).SendAsync("UpdatePartyView",
                                                                           new
            {
                Song     = party.GetCurrentSong(),
                Position = party.GetCurrentPositionInSong()
            },
                                                                           party.GetHistory(),
                                                                           party.GetQueue()
                                                                           );
        }
예제 #2
0
        public async Task SkipSong_HostSkipsSong_SongIsSkipped()
        {
            PartyGoer host = new PartyGoer("Kip", EXPLICIT, MARKET, PRODUCT);

            Party party = new Party(host);

            List <Domain.Track> tracks = GetTracks();

            await party.AddNewQueueAsync(tracks);

            Assert.AreEqual(party.GetCurrentSong().Id, tracks.ElementAt(0).Id);

            await party.RequestSkipAsync(host);

            Assert.AreEqual(party.GetCurrentSong().Id, tracks.ElementAt(1).Id);
        }
예제 #3
0
        public async Task DownVote_HostDownVotesSong_SongSkips()
        {
            PartyGoer host = new PartyGoer("Kip", EXPLICIT, MARKET, PRODUCT);

            Party party = new Party(host);

            List <Domain.Track> tracks = GetTracks();

            await party.AddNewQueueAsync(tracks);

            Assert.AreEqual(party.GetCurrentSong().Id, tracks.ElementAt(0).Id);

            await party.UserDislikesTrackAsync(host, tracks.ElementAt(0).Id);

            Assert.AreEqual(party.GetCurrentSong().Id, tracks.ElementAt(1).Id);
        }
예제 #4
0
        public async Task SkipSong_EndOfPlaylist_GeneratesNewPlaylistEvent()
        {
            DomainEvents.Register <QueueEnded>((p) =>
            {
                Assert.Pass();
            });

            PartyGoer host = new PartyGoer("Kip", EXPLICIT, MARKET, PRODUCT);

            Party party = new Party(host);

            List <Domain.Track> tracks = GetTracks();

            await party.AddNewQueueAsync(tracks);

            Assert.AreEqual(party.GetCurrentSong().Id, tracks.ElementAt(0).Id);

            await party.RequestSkipAsync(host);

            await party.RequestSkipAsync(host);

            Assert.Fail();
        }