예제 #1
0
        public async Task DeleteChannelClearsEpisodes()
        {
            var channel = new Channel("link")
            {
                Id = 1
            };

            ChannelStore.GetAllAsync().Returns(new List <Channel>
            {
                channel
            });
            ChannelStore.Remove(Arg.Is(channel)).Returns(1);

            await PodcastViewModel.InitChannels();

            PodcastViewModel.Channels.Should().NotBeEmpty();
            PodcastViewModel.EpisodeList.MonitorEvents();

            await PodcastViewModel.DeleteChannel(channel);

            PodcastViewModel.EpisodeList.ShouldRaise("CollectionChanged")
            .WithSender(PodcastViewModel.EpisodeList)
            .WithArgs <NotifyCollectionChangedEventArgs>(args => args.Action == NotifyCollectionChangedAction.Reset);

            PodcastViewModel.Channels.Should().BeEmpty("the channel was deleted");
        }
예제 #2
0
        public async Task UpdateChannelsSavesEpisodes()
        {
            // channel
            var channel = new Channel("dummyLink");

            var newEpisode = new Episode
            {
                Title = "new episode"
            };
            var channels = new List <Channel>
            {
                channel
            };

            ChannelStore.GetAllAsync().Returns(channels);
            ChannelStore.GetChannelInfos().Returns(channels.Select(_ => new ChannelInfo
            {
                Id           = _.Id,
                FeedUrl      = _.Link,
                ImageUrl     = _.ImageUrl,
                EpisodeInfos = _.Episodes.Select(x => new EpisodeInfo
                {
                    Id   = x.Guid,
                    Date = x.Date
                })
            }));

            await PodcastViewModel.InitChannels();

            PodcastViewModel.FeedParser.LoadFeed(Arg.Any <string>()).Returns(new ItunesFeed());
            PodcastViewModel.FeedParser.ParseItems(Arg.Any <IEnumerable <ItunesItem> >(), Arg.Any <ChannelInfo>())
            .Returns(new[]
            {
                newEpisode
            });

            PodcastViewModel.UpdateCancelToken = new CancellationTokenSource();
            await PodcastViewModel.UpdateChannelsCommand.Execute();

            // assert
            await ChannelStore.Received(1).SaveEpisodes(Arg.Is <IEnumerable <Episode> >(_ => _.Contains(newEpisode)));

            //Repository.All<Episode>().Should().Contain(newEpisode);

            //await DbContext.Received(1).SaveChangesAsync();
        }
예제 #3
0
        public async Task ChannelMoveTriggersReorder()
        {
            var channel1 = new Channel("DummyLink1")
            {
                OrderNumber = 1
            };

            var channel2 = new Channel("DummyLink2")
            {
                OrderNumber = 2
            };

            var channels = new List <Channel>
            {
                channel1,
                channel2
            };

            ChannelStore.GetAllAsync().Returns(channels);
            ChannelStore.ChangeOrderAsync(Arg.Is(channel1), Arg.Is(2)).Returns(Task.FromResult(2)).AndDoes(_ =>
            {
                channel1.OrderNumber = 2;
                channel2.OrderNumber = 1;
            });

            await PodcastViewModel.InitChannels();

            // move channel1 to second position (i.e. index 1)
            PodcastViewModel.Channels.Should().HaveCount(2);
            await PodcastViewModel.MoveItemToIndex(channel1, 2);

            // channel 2 is now in first position
            PodcastViewModel.ChannelView.First().Should().Be(channel2);
            // channel 1 is now in second position
            PodcastViewModel.ChannelView.Skip(1).First().Should().Be(channel1);
        }