Ejemplo n.º 1
0
        private static Tuple<LocalSong, byte[]> CreateSong(Tag tag, TimeSpan duration, string filePath)
        {
            var song = new LocalSong(filePath, duration)
            {
                Album = PrepareTag(tag.Album, String.Empty),
                Artist = PrepareTag(tag.FirstAlbumArtist ?? tag.FirstPerformer, "Unknown Artist"), //HACK: In the future retrieve the string for an unkown artist from the view if we want to localize it
                Genre = PrepareTag(tag.FirstGenre, String.Empty),
                Title = PrepareTag(tag.Title, Path.GetFileNameWithoutExtension(filePath)),
                TrackNumber = (int)tag.Track
            };

            IPicture picture = tag.Pictures.FirstOrDefault();

            return Tuple.Create(song, picture == null ? null : picture.Data.Data);
        }
            public void MultipleSongsWithSameArtistReturnsCommonArtist()
            {
                var song1 = new LocalSong("C://song1.mp3", TimeSpan.Zero)
                {
                    Artist = "The Artist"
                };

                var song2 = new LocalSong("C://song2.mp3", TimeSpan.Zero)
                {
                    Artist = "The Artist"
                };

                var songs = new[] { song1, song2 };
                var fixture = new TagEditorViewModel(songs, () => Task.FromResult(true));

                Assert.Equal(song1.Artist, fixture.Artist);
            }
Ejemplo n.º 3
0
            public async Task IsTrueForUpdatedLibrary()
            {
                var song = new LocalSong("C://Song.mp3", TimeSpan.Zero);

                var songFinder = Substitute.For<ILocalSongFinder>();
                songFinder.GetSongsAsync().Returns(Observable.Return(Tuple.Create(song, (byte[])null)));

                var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { "C://Song.mp3", new MockFileData("Bla") } });

                using (Library library = new LibraryBuilder().WithFileSystem(fileSystem).WithSongFinder(songFinder).Build())
                {
                    Guid accessToken = library.LocalAccessControl.RegisterLocalAccessToken();

                    // NB: System.IO.Abstractions only likes backslashes
                    library.ChangeSongSourcePath("C:\\", accessToken);

                    var vm = new LocalViewModel(library, new ViewSettings(), new CoreSettings(), accessToken);

                    await library.AwaitInitializationAndUpdate();

                    Assert.False(vm.ShowAddSongsHelperMessage);
                }
            }