Exemple #1
0
        public void TestGetShows()
        {
            var podcastFeedProvider = new Mock <IPodcastFeedProvider>();

            podcastFeedProvider.Setup(provider => provider.Get(""))
            .Returns(new PodcastFeed
            {
                FeedItems = new List <PodcastFeedItem>
                {
                    new PodcastFeedItem()
                }
            });

            var podcastProvider = new Mock <IPodcastProvider>();

            podcastProvider.Setup(provider => provider.GetShows("testChannel"))
            .Returns(new List <Show> {
                new Show {
                    Title = "TestTitle", XmlLink = "http://www.dr.dk"
                }
            });

            var controller = new PodcastController(podcastFeedProvider.Object, podcastProvider.Object);

            var result = controller.GetShows("testChannel") as JsonResult;

            Assert.IsNotNull(result);
            var listItems = ((IEnumerable <SelectListItem>)result.Data).ToList();

            Assert.AreEqual(2, listItems.Count());
            Assert.IsNotNull(listItems.Single(li => li.Text == "TestTitle"));
        }