Beispiel #1
0
        public async Task Playlists_ShouldLoad()
        {
            var container = await DependencyInjectionFactory.Get().ConfigureAwait(false);

            var dummyPlaylists = new List <Playlist>
            {
                container.CreatePlaylist(_context.CreateModelPlaylist()),
            };
            var repository = ContainerContextExtensions.CreateRepository();

            repository.GetPlaylistsAsync().ReturnsForAnyArgs(dummyPlaylists);
            container.UseInstance(repository);

            var playlists = (Playlists)container.Resolve <IPlaylistsViewModel>();

            repository.ClearReceivedCalls();

            await playlists.LoadAsync().ConfigureAwait(false);

            await repository.Received(1).GetPlaylistsAsync().ConfigureAwait(false);

            repository.Received(1).Dispose();

            Assert.AreEqual(dummyPlaylists[0], playlists.SelectedItem);
            Assert.AreEqual(1, playlists.Count);
        }
Beispiel #2
0
        public async Task Playlists_ShouldSave()
        {
            var container = await DependencyInjectionFactory.Get().ConfigureAwait(false);

            var repository = ContainerContextExtensions.CreateRepository();

            container.UseInstance(repository);

            var playlists = container.Resolve <IPlaylistsViewModel>();

            repository.ClearReceivedCalls();

            playlists.Save();

            repository.Received(1).Save(NSubstitute.Arg.Any <Playlists>());
            repository.Received(1).Dispose();
        }