Пример #1
0
        // ReSharper disable once InconsistentNaming
        public async Task PopulateShowAsync_should_add_existing_network()
        {
            var repository = Substitute.For<INetworkRepository>();

            var data = new Series
            {
                Network = "bbc"
            };

            var network = new Network(data.Network);

            repository.GetNetworkByNameAsync(data.Network).Returns(network);

            var fetcher = new ShowFetcher(repository);

            var show = new Show();

            await fetcher.PopulateShowAsync(show, data);

            await repository.Received().GetNetworkByNameAsync(data.Network);

            Assert.Equal(network, show.Network);
        }
Пример #2
0
        // ReSharper disable once InconsistentNaming
        public async Task PopulateShowAsync_should_replace_existing_network()
        {
            var data = new Series
            {
                Network = "bbc 2"
            };

            var fetcher = CreateFetcher();

            var network = new Network("bbc");

            var show = new Show
            {
                Network = network
            };

            await fetcher.PopulateShowAsync(show, data);

            Assert.Equal(data.Network, show.Network.Name);
        }
Пример #3
0
        private static async Task SeedGenresAsync(TrackTvDbContext context, IEnumerable<Show> shows = null)
        {
            if (shows == null)
            {
                var network = new Network("bbc");
                var genre = new Genre("action");
                var user = new User
                {
                    Username = "******"
                };
                var actor = new Actor
                {
                    Name = "Cat"
                };

                shows = new[]
                {
                    CreateShow("Show1", 1000, network, genre, actor, user),
                    CreateShow("Show2", 1001, network, genre, actor, user),
                    CreateShow("Show3", 1002, network, genre, actor, user),
                    CreateShow("Show4", 1003, network, genre, actor, user),
                    CreateShow("Show5", 1004, network, genre, actor, user)
                };
            }

            context.Shows.AddRange(shows);
            await context.SaveChangesAsync();
        }
Пример #4
0
        // ReSharper disable once InconsistentNaming
        public async Task PopulateShowAsync_should_not_replace_the_network_if_it_has_the_same_name()
        {
            var data = new Series
            {
                Network = "bbc"
            };

            var fetcher = CreateFetcher();

            var network = new Network(data.Network);

            var show = new Show
            {
                Network = network
            };

            await fetcher.PopulateShowAsync(show, data);

            Assert.Equal(network, show.Network);
        }
Пример #5
0
 private static Show CreateShow(string name, int theTvDbId, Network network, Genre genre, Actor actor, User user)
 {
     return new Show
     {
         Name = name,
         TheTvDbId = theTvDbId,
         Network = network,
         ShowsGenres = {
             new ShowsGenres(genre)
         },
         ShowsActors = {
             new ShowsActors
             {
                 Actor = actor
             }
         },
         ShowsUsers = {
             new ShowsUsers
             {
                 User = user
             }
         },
         Episodes = {
             new Episode
             {
                 Title = "Title"
             }
         }
     };
 }