예제 #1
0
        public void AlbumArtPopupViewModel_ProfileChangedEvent_ListensToProfileChanges()
        {
            var first = new UserProfile()
            {
                AlbumArtPopup = new AlbumArtPopup()
                {
                    Height = 10
                }
            };

            var second = new UserProfile
            {
                AlbumArtPopup = new AlbumArtPopup()
                {
                    Height = 20
                }
            };

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

            var vm = new AlbumArtPopupViewModel(_appSettings.Object, _messageBus.Object);

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

            Assert.False(vm.IsEditing);
            Assert.Equal(second.AlbumArtPopup.Height, vm.Height);
        }
예제 #2
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;
 }
예제 #3
0
        public void AlbumArtPopupViewModel_UsesMessageBus()
        {
            var profile = new UserProfile
            {
                AlbumArtPopup = new AlbumArtPopup()
            };

            _appSettings.SetupGet(m => m.CurrentProfile).Returns(profile);
            var vm = new AlbumArtPopupViewModel(_appSettings.Object, _messageBus.Object);

            _messageBus.Verify(m => m.Subscribe(It.IsAny <Action <EditEndMessage> >()));
        }
예제 #4
0
        public void AlbumArtPopupViewModel_EndEdit_WritesChangesToAppSettings()
        {
            var profile = new UserProfile
            {
                AlbumArtPopup = new AlbumArtPopup {
                    Width = 50
                }
            };
            const int newWidth = 100;

            _appSettings.SetupGet(m => m.CurrentProfile).Returns(profile);
            var vm = new AlbumArtPopupViewModel(_appSettings.Object, _messageBus.Object);

            vm.Width = newWidth;
            vm.EndEdit();

            Assert.Equal(newWidth, profile.AlbumArtPopup.Width);
        }
예제 #5
0
        public void AlbumArtPopupViewModel_CancelEdit_DoesNotWriteChangesToAppSettings()
        {
            const int initialWidth = 50;
            var       profile      = new UserProfile
            {
                AlbumArtPopup = new AlbumArtPopup {
                    Width = initialWidth
                }
            };
            const int newWidth = 100;

            _appSettings.SetupGet(m => m.CurrentProfile).Returns(profile);
            var vm = new AlbumArtPopupViewModel(_appSettings.Object, _messageBus.Object);

            vm.Width = newWidth;
            vm.CancelEdit();

            Assert.Equal(initialWidth, profile.AlbumArtPopup.Width);
        }
예제 #6
0
        public void ListensForProfileChangesAndMapsProperly()
        {
            var first = new AlbumArtPopup()
            {
                Height = 10
            };
            var second = new AlbumArtPopup()
            {
                Height = 20
            };

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

            var vm = new AlbumArtPopupViewModel(_appSettings.Object, _messageBus.Object);

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

            Assert.IsFalse(vm.IsEditing);
            Assert.AreEqual(second.Height, vm.Height);
        }