public void Load_ForDeletedDiscWithVariousDeleteCommentsForSongs_LoadsDeleteCommentCorrectly()
        {
            // Arrange

            var disc = new DiscModel
            {
                Title     = "Some Title",
                TreeTitle = "Some Tree Title",
            };

            disc.AddSongs(new SongModel {
                DeleteDate = new DateTime(2021, 10, 25), DeleteComment = "Boring"
            });
            disc.AddSongs(new SongModel {
                DeleteDate = new DateTime(2021, 10, 25), DeleteComment = "Boring too"
            });

            var mocker = new AutoMocker();
            var target = mocker.CreateInstance <EditDiscPropertiesViewModel>();

            // Act

            target.Load(disc);

            // Assert

            target.IsDeleted.Should().BeTrue();
            target.DeleteComment.Should().Be("<Songs have various delete comments>");
        }
        public void Load_ForDeletedDiscWithSameDeleteCommentForAllSongs_LoadsPropertiesCorrectly()
        {
            // Arrange

            var disc = new DiscModel
            {
                Title      = "Some Title",
                TreeTitle  = "Some Tree Title",
                AlbumTitle = "Some Album Title",
                Year       = 2021,
            };

            disc.AddSongs(new SongModel {
                DeleteDate = new DateTime(2021, 10, 25), DeleteComment = "Boring"
            });
            disc.AddSongs(new SongModel {
                DeleteDate = new DateTime(2021, 10, 25), DeleteComment = "Boring"
            });

            var mocker = new AutoMocker();
            var target = mocker.CreateInstance <EditDiscPropertiesViewModel>();

            // Act

            target.Load(disc);

            // Assert

            target.IsDeleted.Should().BeTrue();
            target.Title.Should().Be("Some Title");
            target.TreeTitle.Should().Be("Some Tree Title");
            target.AlbumTitle.Should().Be("Some Album Title");
            target.Year.Should().Be(2021);
            target.DeleteComment.Should().Be("Boring");
        }
        public async Task Save_ForDeletedDiscWithVariousDeleteCommentWhenDeleteCommentWasNotChanged_UpdatesDiscCorrectly()
        {
            // Arrange

            var disc = new DiscModel
            {
                Title      = "Old Title",
                TreeTitle  = "Old Tree Title",
                AlbumTitle = "Old Album Title",
                Year       = 2021,
            };

            disc.AddSongs(new SongModel {
                DeleteDate = new DateTime(2021, 10, 25), DeleteComment = "Some Delete Comment 1"
            });
            disc.AddSongs(new SongModel {
                DeleteDate = new DateTime(2021, 10, 25), DeleteComment = "Some Delete Comment 2"
            });

            var mocker = new AutoMocker();
            var target = mocker.CreateInstance <EditDiscPropertiesViewModel>();

            target.Load(disc);

            // Act

            target.Title      = "New Title";
            target.TreeTitle  = "New Tree Title";
            target.AlbumTitle = "New Album Title";
            target.Year       = 2021;

            await target.Save(CancellationToken.None);

            // Assert

            Func <Action <DiscModel>, bool> verifyDiscUpdate = updateAction =>
            {
                updateAction(disc);
                return(disc.Title == "New Title" && disc.TreeTitle == "New Tree Title" && disc.AlbumTitle == "New Album Title" && disc.Year == 2021);
            };

            var discServiceMock = mocker.GetMock <IDiscsService>();

            discServiceMock.Verify(x => x.UpdateDisc(disc, It.Is <Action <DiscModel> >(y => verifyDiscUpdate(y)), It.IsAny <CancellationToken>()), Times.Once);

            var songServiceMock = mocker.GetMock <ISongsService>();

            songServiceMock.Verify(x => x.UpdateSong(It.IsAny <SongModel>(), It.IsAny <Action <SongModel> >(), It.IsAny <CancellationToken>()), Times.Never);
        }
        public void DeleteSongsFromDisc_IfSongsAreDeleted_SongItemsAreRemovedFromList()
        {
            // Arrange

            var songs = new[]
            {
                new SongModel {
                    Id = new ItemId("0")
                },
                new SongModel {
                    Id = new ItemId("1")
                },
                new SongModel {
                    Id = new ItemId("2")
                },
                new SongModel {
                    Id = new ItemId("3")
                },
            };

            var disc = new DiscModel();

            disc.AddSongs(songs);

            var mocker = new AutoMocker();
            var target = mocker.CreateInstance <DiscSongListViewModel>();

            mocker.GetMock <IViewNavigator>().Setup(x => x.ShowDeleteDiscSongsView(It.IsAny <IReadOnlyCollection <SongModel> >()))
            .Callback <IReadOnlyCollection <SongModel> >(deletedSongs =>
            {
                foreach (var song in deletedSongs)
                {
                    song.MarkAsDeleted(new DateTime(2021, 07, 11), "Test deletion");
                }
            })
            .Returns(true);

            Messenger.Default.Send(new LibraryExplorerDiscChangedEventArgs(disc, deletedContentIsShown: false));

            // Act

            target.DeleteSongsFromDisc(new[] { songs[0], songs[2] });

            // Assert

            var expectedSongs = new[]
            {
                songs[1],
                songs[3],
            };

            target.Songs.Should().BeEquivalentTo(expectedSongs, x => x.WithStrictOrdering());
        }
Пример #5
0
        public void ToolTipGetter_ForDeletedDiscWithVariousDeleteDateAndComments_ReturnsCorrectValue()
        {
            // Arrange

            var disc = new DiscModel();

            disc.AddSongs(new SongModel {
                DeleteDate = new DateTime(2021, 10, 25), DeleteComment = "Boring 1"
            });
            disc.AddSongs(new SongModel {
                DeleteDate = new DateTime(2021, 10, 26), DeleteComment = "Boring 2"
            });

            var target = new DiscExplorerItem(disc);

            // Act

            var toolTip = target.ToolTip;

            // Assert

            toolTip.Should().Be("The disc was deleted with various comments");
        }
Пример #6
0
        public void ToolTipGetter_ForDeletedDiscWithSameDeleteDateAndWithoutComment_ReturnsCorrectValue()
        {
            // Arrange

            var disc = new DiscModel();

            disc.AddSongs(new SongModel {
                DeleteDate = new DateTime(2021, 10, 26), DeleteComment = null
            });
            disc.AddSongs(new SongModel {
                DeleteDate = new DateTime(2021, 10, 26), DeleteComment = null
            });

            var target = new DiscExplorerItem(disc);

            // Act

            var toolTip = target.ToolTip;

            // Assert

            toolTip.Should().Be("The disc was deleted on 2021.10.26 without comment");
        }
        public void LibraryExplorerDiscChangedEventHandler_IfDeletedContentIsNotShown_FillsListWithActiveDiscSongs()
        {
            // Arrange

            var oldSongs = new[]
            {
                new SongModel {
                    Id = new ItemId("Old 0")
                },
                new SongModel {
                    Id = new ItemId("Old 1")
                },
            };

            var newSongs = new[]
            {
                new SongModel {
                    Id = new ItemId("New 0")
                },
                new SongModel {
                    Id = new ItemId("New 1"), DeleteDate = new DateTime(2021, 07, 25)
                },
                new SongModel {
                    Id = new ItemId("New 2")
                },
            };

            var newDisc = new DiscModel();

            newDisc.AddSongs(newSongs);

            var mocker = new AutoMocker();
            var target = mocker.CreateInstance <DiscSongListViewModel>();

            target.SetSongs(oldSongs);

            // Act

            Messenger.Default.Send(new LibraryExplorerDiscChangedEventArgs(newDisc, deletedContentIsShown: false));

            // Assert

            var expectedSongs = new[]
            {
                newSongs[0],
                newSongs[2],
            };

            target.Songs.Should().BeEquivalentTo(expectedSongs, x => x.WithStrictOrdering());
        }
        public void DeleteSongsFromDisc_IfSongsAreNotDeleted_DoesNotReloadSongList()
        {
            // Arrange

            var songs = new[]
            {
                new SongModel {
                    Id = new ItemId("0")
                },
                new SongModel {
                    Id = new ItemId("1")
                },
                new SongModel {
                    Id = new ItemId("2")
                },
                new SongModel {
                    Id = new ItemId("3")
                },
            };

            var disc = new DiscModel();

            disc.AddSongs(songs);

            var mocker = new AutoMocker();
            var target = mocker.CreateInstance <DiscSongListViewModel>();

            mocker.GetMock <IViewNavigator>().Setup(x => x.ShowDeleteDiscSongsView(It.IsAny <IReadOnlyCollection <SongModel> >()))
            .Callback <IReadOnlyCollection <SongModel> >(deletedSongs =>
            {
                foreach (var song in deletedSongs)
                {
                    // In real life when ShowDeleteDiscSongsView returns false, the songs are not actually deleted.
                    // This is just a convenient way to check that song list is not reloaded.
                    song.MarkAsDeleted(new DateTime(2021, 07, 11), "Test deletion");
                }
            })
            .Returns(false);

            Messenger.Default.Send(new LibraryExplorerDiscChangedEventArgs(disc, deletedContentIsShown: false));

            // Act

            target.DeleteSongsFromDisc(new[] { songs[0], songs[2] });

            // Assert

            target.Songs.Should().BeEquivalentTo(songs, x => x.WithStrictOrdering());
        }
        public void PlayDisc_SendsPlaySongsListEventForActiveDiscSongs()
        {
            // Arrange

            var disc = new DiscModel {
                Id = new ItemId("Some Disc")
            };
            var discFolder = new FolderModel {
                Id = new ItemId("Some Folder")
            };

            discFolder.AddDiscs(disc);

            var activeSong1 = new SongModel {
                Id = new ItemId("Active Song 1")
            };
            var activeSong2 = new SongModel {
                Id = new ItemId("Active Song 2")
            };
            var deletedSong = new SongModel {
                Id = new ItemId("Deleted Songs"), DeleteDate = new DateTime(2021, 07, 25)
            };

            disc.AddSongs(activeSong1, deletedSong, activeSong2);

            var mocker = new AutoMocker();
            var target = mocker.CreateInstance <LibraryExplorerViewModel>();

            PlaySongsListEventArgs playSongsListEvent = null;

            Messenger.Default.Register <PlaySongsListEventArgs>(this, e => e.RegisterEvent(ref playSongsListEvent));

            // Act

            target.PlayDisc(disc);

            // Assert

            var expectedSongs = new[]
            {
                activeSong1,
                activeSong2,
            };

            playSongsListEvent.Should().NotBeNull();
            playSongsListEvent.Songs.Should().BeEquivalentTo(expectedSongs, x => x.WithStrictOrdering());
        }
Пример #10
0
        public void ForAdviseSet_IfAdviseSetContainsMultipleDiscs_OrdersPlaylistSongsCorrectly()
        {
            // Arrange

            var adviseSet = new AdviseSetModel {
                Id = new ItemId("Advise Set Id"), Name = "Some Advise Set"
            };

            var disc1 = new DiscModel
            {
                Id            = new ItemId("1"),
                TreeTitle     = "Disc 1",
                AdviseSetInfo = new AdviseSetInfo(adviseSet, 2),
            };

            var song11 = new SongModel {
                Id = new ItemId("Song 1.1")
            };
            var song12 = new SongModel {
                Id = new ItemId("Song 1.2")
            };

            disc1.AddSongs(song11, song12);

            var disc2 = new DiscModel
            {
                Id            = new ItemId("2"),
                TreeTitle     = "Disc 2",
                AdviseSetInfo = new AdviseSetInfo(adviseSet, 1),
            };

            var song2 = new SongModel {
                Id = new ItemId("Song 2.1")
            };

            disc2.AddSongs(song2);

            var disc3 = new DiscModel
            {
                Id            = new ItemId("3"),
                TreeTitle     = "Disc 3",
                AdviseSetInfo = new AdviseSetInfo(adviseSet, 3),
            };

            var song3 = new SongModel {
                Id = new ItemId("Song 3.1")
            };

            disc3.AddSongs(song3);

            var adviseSetContent = new AdviseSetContent("AdviseSetContent Id");

            adviseSetContent.AddDisc(disc1);
            adviseSetContent.AddDisc(disc2);
            adviseSetContent.AddDisc(disc3);

            // Act

            var target = AdvisedPlaylist.ForAdviseSet(adviseSetContent);

            // Assert

            var expectedSongs = new[]
            {
                song2,
                song11,
                song12,
                song3,
            };

            target.Songs.Should().BeEquivalentTo(expectedSongs, x => x.WithStrictOrdering());
        }