示例#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);
        }
示例#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();
        }
示例#3
0
        public async Task Playlists_ShouldAdd()
        {
            var container = await DependencyInjectionFactory.Get().ConfigureAwait(false);

            var sequenceProvider = ContainerContextExtensions.CreateSequenceService();

            sequenceProvider.Get(default(List <ISequence>)).ReturnsForAnyArgs(5);
            container.UseInstance(sequenceProvider);

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

            Assert.AreEqual(0, playlists.Count);
            sequenceProvider.ClearReceivedCalls();

            playlists.Add();

            sequenceProvider.Received(1).Get(NSubstitute.Arg.Any <IList <ISequence> >());

            Assert.AreEqual(1, playlists.Count);
            Assert.AreEqual(5, playlists.Items.First().Sequence);
        }