Example #1
0
        public void StopMessage()
        {
            var rawNubs = new Dictionary<string, object>();
            rawNubs.Add("action", PubnubMessage.ACTION_STOP);

            var playerStub = MockRepository.GenerateStub<IPlayer>();
            playerStub.Stub(X => X.Stop());

            var pubnub = new PubnubMessaging(playerStub, false);

            pubnub.HandleMessage(rawNubs);

            playerStub.AssertWasCalled(X => X.Stop());
        }
        public void SimpleTranslation()
        {
            var rawNubs = new Dictionary<string, object>();
            rawNubs.Add("action", PubnubMessage.ACTION_PLAY);

            var expected = new PubnubMessage()
                {
                    action = PubnubMessage.ACTION_PLAY
                };

            var pubnub = new PubnubMessaging(null, false);
            PubnubMessage result = pubnub.Translate(rawNubs);

            Assert.AreEqual(expected.action, result.action, "The action must be correct.");
        }
Example #3
0
        private void StartPlayer()
        {
            try
            {
                var playlistManager = GetPlaylistManager();
                var messagingWatcher = new MessagingPlaylistWatcher();
                var playlist = new Playlist(new IPlaylistWatcher[] { playlistManager, messagingWatcher });
                var dummyAudio = new NAudioInteractor();
                var library = new MongoLibraryRepository(null);
                _folderWatcher = new ImportFolderWatcher(library);

                if (ConfigurationManager.AppSettings["ResetLibraryForTesting"]=="true")
                    InsertTestSongs(library);

                var player = new Player(playlist, dummyAudio, library);
                _pubnub = new PubnubMessaging(player, true);

                messagingWatcher.AssignMessaging(_pubnub);
                messagingWatcher.AttachToPlaylist(playlist, library);
                playlistManager.AttachToPlaylist(playlist, library);

                _pubnub.StartListening();

                library.Messaging = _pubnub;

                _folderWatcher.Start();

                if (ConfigurationManager.AppSettings["AutoStartPlaying"]=="true")
                    player.Play();

                _pubnub.SendNowPlaying(playlist[0]);
            }
            catch (Exception exc)
            {
                Log.Debug(exc.ToString());
            }
        }