Пример #1
0
        public async Task RepeatModeButton_RepeatCommandExecuted_CyclesThroughRepeatModes()
        {
            var repeatSequence  = new[] { RepeatMode.RepeatContext, RepeatMode.RepeatTrack, RepeatMode.Off };
            var index           = 0;
            var audiosourceMock = new Mock <IInternalAudioSource>();

            audiosourceMock.Setup(m => m.SetRepeatModeAsync(It.IsAny <RepeatMode>()))
            .Callback((RepeatMode mode) => Assert.Equal(repeatSequence[index++], mode))
            .Returns(Task.CompletedTask);
            _appSettings.SetupGet(m => m.CurrentProfile).Returns(new UserProfile()
            {
                RepeatModeButton = new RepeatModeButton()
            });
            _session.SetupGet(m => m.CurrentAudioSource).Returns(audiosourceMock.Object);
            _session.SetupSequence(m => m.RepeatMode)
            .Returns(RepeatMode.RepeatContext)
            .Returns(RepeatMode.RepeatTrack)
            .Returns(RepeatMode.Off)
            ;

            var viewModel = new RepeatModeButtonViewModel(_appSettings.Object, _dialog.Object, _session.Object, _messageBus.Object);

            Assert.Equal(RepeatMode.Off, viewModel.RepeatMode);
            await viewModel.CycleRepeatModeCommand.ExecuteAsync(null);

            _session.Raise(m => m.PropertyChanged += null, null, new PropertyChangedEventArgs(nameof(IAudioSession.RepeatMode)));
            await viewModel.CycleRepeatModeCommand.ExecuteAsync(null);

            _session.Raise(m => m.PropertyChanged += null, null, new PropertyChangedEventArgs(nameof(IAudioSession.RepeatMode)));
            await viewModel.CycleRepeatModeCommand.ExecuteAsync(null);
        }
Пример #2
0
        public void RepeatModeButton_ProfileChanged_ListensForProfileChanges()
        {
            var first = new UserProfile()
            {
                RepeatModeButton = new RepeatModeButton()
                {
                    Height = 1
                }
            };
            var second = new UserProfile()
            {
                RepeatModeButton = new RepeatModeButton()
                {
                    Height = 2
                }
            };

            _appSettings.SetupSequence(m => m.CurrentProfile)
            .Returns(first)
            .Returns(second);

            var  vm     = new RepeatModeButtonViewModel(_appSettings.Object, _dialog.Object, _session.Object, _messageBus.Object);
            bool raised = false;

            vm.PropertyChanged += (_, __) => raised = true;

            Assert.Equal(first.RepeatModeButton.Height, vm.Height);
            _appSettings.Raise(m => m.ProfileChanged += null, EventArgs.Empty);

            Assert.False(vm.IsEditing);
            Assert.True(raised);
            Assert.Equal(second.RepeatModeButton.Height, vm.Height);
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewModelContainer"/> class.
 /// </summary>
 /// <param name="generalSettingsViewModel">Audioband view model.</param>
 /// <param name="albumArtPopupViewModel">Album art popup view model.</param>
 /// <param name="albumArtViewModel">Album art view model.</param>
 /// <param name="customLabelsViewModel">Custom labels view model.</param>
 /// <param name="nextButtonViewModel">Next button view model.</param>
 /// <param name="playPauseButtonViewModel">Play pause button view model.</param>
 /// <param name="repeatModeButtonViewModel">Repeat mode button view model.</param>
 /// <param name="shuffleModeButtonViewModel">Shuffle mode button view model.</param>
 /// <param name="previousButtonViewModel">Previous button view model.</param>
 /// <param name="progressBarViewModel">Progress bar view model.</param>
 /// <param name="audioSourceSettingsViewModel">Audio source settings view model.</param>
 public ViewModelContainer(
     GeneralSettingsViewModel generalSettingsViewModel,
     AlbumArtPopupViewModel albumArtPopupViewModel,
     AlbumArtViewModel albumArtViewModel,
     CustomLabelsViewModel customLabelsViewModel,
     NextButtonViewModel nextButtonViewModel,
     PlayPauseButtonViewModel playPauseButtonViewModel,
     RepeatModeButtonViewModel repeatModeButtonViewModel,
     ShuffleModeButtonViewModel shuffleModeButtonViewModel,
     PreviousButtonViewModel previousButtonViewModel,
     ProgressBarViewModel progressBarViewModel,
     AudioSourceSettingsViewModel audioSourceSettingsViewModel)
 {
     GeneralSettingsViewModel     = generalSettingsViewModel;
     AlbumArtPopupViewModel       = albumArtPopupViewModel;
     AlbumArtViewModel            = albumArtViewModel;
     CustomLabelsViewModel        = customLabelsViewModel;
     NextButtonViewModel          = nextButtonViewModel;
     PlayPauseButtonViewModel     = playPauseButtonViewModel;
     RepeatModeButtonViewModel    = repeatModeButtonViewModel;
     ShuffleModeButtonViewModel   = shuffleModeButtonViewModel;
     PreviousButtonViewModel      = previousButtonViewModel;
     ProgressBarViewModel         = progressBarViewModel;
     AudioSourceSettingsViewModel = audioSourceSettingsViewModel;
 }
Пример #4
0
        public void RepeatModeButtonMarkedAsEditingWhenContentIsEditing()
        {
            _appSettings.SetupGet(m => m.RepeatModeButton).Returns(new RepeatModeButton());
            var viewModel = new RepeatModeButtonViewModel(_appSettings.Object, _dialog.Object, _session.Object, _messageBus.Object);

            Assert.IsFalse(viewModel.RepeatTrackContent.IsEditing);
            Assert.IsFalse(viewModel.IsEditing);

            viewModel.RepeatTrackContent.Text = "test";

            Assert.IsTrue(viewModel.RepeatTrackContent.IsEditing);
            Assert.IsTrue(viewModel.IsEditing);
        }
Пример #5
0
        public void RepeatModeButton_ContentPropertiesAreModified_ViewModelIsMarkedAsEditing()
        {
            _appSettings.SetupGet(m => m.CurrentProfile).Returns(new UserProfile()
            {
                RepeatModeButton = new RepeatModeButton()
            });
            var viewModel = new RepeatModeButtonViewModel(_appSettings.Object, _dialog.Object, _session.Object, _messageBus.Object);

            Assert.False(viewModel.RepeatTrackContent.IsEditing);
            Assert.False(viewModel.IsEditing);

            viewModel.RepeatTrackContent.Text = "test";

            Assert.True(viewModel.RepeatTrackContent.IsEditing);
            Assert.True(viewModel.IsEditing);
        }