Exemplo n.º 1
0
 public async Task SyncContestants()
 {
     var contestants = FileContestantRequestFactory.GetContestants();
     var sqlServerConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WarDb"].ConnectionString;
     var synchronizer = new ContestantSynchronizer();
     await synchronizer.SyncContestants(sqlServerConnectionString, contestants, 1, "Movie War", IsTheSame);
 }
Exemplo n.º 2
0
        public async Task GivenMovieIdentifiers_Create_ReturnsContestantRequests()
        {
            // Arrange
            var items   = GetMovieIdentifiersFromFile();
            var factory = new OmdbApiMovieContestantRequestFactory();

            // Act
            var contestants = await factory.Create(items);

            // Assert
            contestants.Should().NotBeNullOrEmpty();
            await FileContestantRequestFactory.WriteMovieContestantsToFile(contestants);
        }
Exemplo n.º 3
0
        public async Task GivenMovieContestantsAndPath_DownloadPostersAndSaveThem()
        {
            var          contestants = FileContestantRequestFactory.GetContestants();
            const string path        = @"C:\posters";

            foreach (var c in contestants)
            {
                try
                {
                    await Download(c, path);
                }
                catch (Exception ex)
                {
                    throw new Exception($"Failed to get poster for {c.Definition["Title"]} ({c.Definition["Year"]})", ex);
                }
            }
        }
Exemplo n.º 4
0
        public async Task GivenMovieContestantsAndUrl_ChangePosterUrlsAndSave()
        {
            var          contestants = FileContestantRequestFactory.GetContestants();
            const string baseUri     = @"http://moviewar.azurewebsites.net/Posters/";

            foreach (var c in contestants)
            {
                try
                {
                    var uri      = c.Definition["Poster"];
                    var filename = GetFileName(uri);
                    var newUri   = baseUri + filename;
                    c.Definition["Poster"] = newUri;
                }
                catch (Exception ex)
                {
                    throw new Exception($"Failed to set poster for {c.Definition["Title"]} ({c.Definition["Year"]})", ex);
                }
            }

            await FileContestantRequestFactory.WriteMovieContestantsToFile(contestants);
        }