Example #1
0
            public async Task TriggersUpdate()
            {
                var fileSystem = new MockFileSystem();
                fileSystem.Directory.CreateDirectory("C://Test");

                using (var library = new LibraryBuilder().WithFileSystem(fileSystem).Build())
                {
                    library.Initialize();

                    var updated = library.WhenAnyValue(x => x.IsUpdating).FirstAsync(x => x).PublishLast();
                    updated.Connect();

                    Guid token = library.LocalAccessControl.RegisterLocalAccessToken();

                    library.ChangeSongSourcePath("C://Test", token);

                    await updated.Timeout(TimeSpan.FromSeconds(5));
                }
            }
Example #2
0
            public async Task SmokeTest()
            {
                var fileSystem = new MockFileSystem();
                fileSystem.Directory.CreateDirectory("C://Test");

                using (var library = new LibraryBuilder().WithFileSystem(fileSystem).Build())
                {
                    Guid token = library.LocalAccessControl.RegisterLocalAccessToken();

                    library.ChangeSongSourcePath("C://Test", token);

                    var isUpdating = library.WhenAnyValue(x => x.IsUpdating).CreateCollection();

                    var last = library.WhenAnyValue(x => x.IsUpdating).Where(x => !x).ElementAt(1).PublishLast();
                    last.Connect();

                    await library.AwaitInitializationAndUpdate();

                    Assert.Equal(new[] { false, true, false }, isUpdating);
                }
            }
Example #3
0
            public async Task SetsCurrentSongIndexIfChangingToOtherPlaylistAndPlayingFirstSong()
            {
                using (Library library = new LibraryBuilder().WithPlaylist().Build())
                {
                    var coll = library.WhenAnyValue(x => x.CurrentPlaylist.CurrentSongIndex).CreateCollection();

                    Guid token = library.LocalAccessControl.RegisterLocalAccessToken();

                    library.AddSongsToPlaylist(new[] { Helpers.SetupSongMock() }, token);

                    await library.PlaySongAsync(0, token);

                    library.AddPlaylist("Playlist 2", token);
                    library.SwitchToPlaylist(library.Playlists.Last(), token);
                    library.AddSongsToPlaylist(new[] { Helpers.SetupSongMock() }, token);

                    await library.PlaySongAsync(0, token);

                    Assert.Equal(new int?[] { null, 0, null, null, 0, null }, coll);
                }
            }