Esempio n. 1
0
        protected override void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);

            if (!_SpotifyController.IsSpotifyInstalled())
            {
                _WindowManager.ShowDialog(TinyIoCContainer.Current.Resolve <NoSpotifyViewModel>());
            }

            if (_Settings.HideIfSpotifyClosed && !_SpotifyController.IsSpotifyOpen())
            {
                OnToggleVisibility(new ToggleVisibilityEventArgs(Visibility.Hidden));
            }
        }
        public async Task TestUpdateViewSuccess()
        {
            var status = new Status
            {
                track = new Track
                {
                    track_resource = new Resource
                    {
                        name     = "TestName",
                        uri      = "SpotifyUri",
                        location = new Location
                        {
                            og = "https://open.spotify.com/track/trackurl"
                        }
                    },
                    artist_resource = new Resource
                    {
                        name = "TestArtistName"
                    }
                },
                playing = true,
                volume  = 0.5
            };

            _spotifyController.IsSpotifyOpen().Returns(true);
            _spotifyController.GetStatus().Returns(status);
            _settings.SpotifyToken = new MiniPie.Core.SpotifyWeb.Token();
            _coverService.FetchCover(status).Returns("TestCover");
            _spotifyController.IsTracksSaved(null).ReturnsForAnyArgs(new[] { true });
            _spotifyController.GetPlaylists().Returns(new List <Playlist>
            {
                new Playlist
                {
                    Id = "TestId"
                }
            });

            await _shellViewModel.UpdateView();

            Assert.Equal("TestName", _shellViewModel.CurrentTrack);
            Assert.Equal("SpotifyUri", _shellViewModel.SpotifyUri);
            Assert.Equal("https://open.spotify.com/track/trackurl", _shellViewModel.TrackUrl);
            Assert.Equal("TestArtistName – TestName", _shellViewModel.TrackFriendlyName);
            Assert.Equal("trackurl", _shellViewModel.TrackId);
            Assert.Equal("TestCover", _shellViewModel.CoverImage);
            Assert.Equal(0.5, _shellViewModel.Volume);

            Assert.Collection(_shellViewModel.Playlists, playlist => Assert.Equal("TestId", playlist.Id));
        }
Esempio n. 3
0
        protected override void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);

            if (_Settings.StartMinimized)
            {
                OnToggleVisibility(new ToggleVisibilityEventArgs(Visibility.Hidden));
            }
            else
            {
                if (_Settings.HideIfSpotifyClosed && !_SpotifyController.IsSpotifyOpen())
                {
                    OnToggleVisibility(new ToggleVisibilityEventArgs(Visibility.Hidden));
                }
            }
        }