From ab628e5de75e10dcd4e5e290c0707d2a916111c4 Mon Sep 17 00:00:00 2001 From: Michael Bisbjerg Date: Sun, 4 Oct 2020 01:45:21 +0200 Subject: [PATCH] Use Task.Delay() --- TMDbLibTests/ClientGuestSessionTests.cs | 18 +++++++++--------- TMDbLibTests/ClientMovieTests.cs | 18 +++++++++--------- TMDbLibTests/ClientTvEpisodeTests.cs | 6 +++--- TMDbLibTests/ClientTvSeasonTests.cs | 6 +++--- TMDbLibTests/ClientTvShowTests.cs | 20 ++++++++++---------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/TMDbLibTests/ClientGuestSessionTests.cs b/TMDbLibTests/ClientGuestSessionTests.cs index 7eb8dff..080cb1b 100644 --- a/TMDbLibTests/ClientGuestSessionTests.cs +++ b/TMDbLibTests/ClientGuestSessionTests.cs @@ -23,7 +23,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 7.5)); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); SearchContainer ratings = await TMDbClient.GetGuestSessionRatedTvEpisodesAsync(); @@ -37,7 +37,7 @@ namespace TMDbLibTests //Assert.True(Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 8)); //// Allow TMDb to cache our changes - //Thread.Sleep(2000); + //await Task.Delay(2000); //ratings = Config.Client.GetGuestSessionRatedTvEpisodesAsync().Sync(); @@ -49,7 +49,7 @@ namespace TMDbLibTests //Assert.True(Config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1)); //// Allow TMDb to cache our changes - //Thread.Sleep(2000); + //await Task.Delay(2000); //ratings = Config.Client.GetGuestSessionRatedTvEpisodesAsync().Sync(); @@ -65,7 +65,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.TvShowSetRatingAsync(IdHelper.House, 7.5)); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); SearchContainer ratings = await TMDbClient.GetGuestSessionRatedTvAsync(); @@ -77,7 +77,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.TvShowSetRatingAsync(IdHelper.House, 8)); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); ratings = await TMDbClient.GetGuestSessionRatedTvAsync(); @@ -89,7 +89,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.TvShowRemoveRatingAsync(IdHelper.House)); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); ratings = await TMDbClient.GetGuestSessionRatedTvAsync(); @@ -105,7 +105,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.MovieSetRatingAsync(IdHelper.Terminator, 7.5)); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); SearchContainer ratings = await TMDbClient.GetGuestSessionRatedMoviesAsync(); @@ -117,7 +117,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.MovieSetRatingAsync(IdHelper.Terminator, 8)); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); ratings = await TMDbClient.GetGuestSessionRatedMoviesAsync(); @@ -129,7 +129,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.MovieRemoveRatingAsync(IdHelper.Terminator)); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); ratings = await TMDbClient.GetGuestSessionRatedMoviesAsync(); diff --git a/TMDbLibTests/ClientMovieTests.cs b/TMDbLibTests/ClientMovieTests.cs index ca6e959..7ec3ac4 100644 --- a/TMDbLibTests/ClientMovieTests.cs +++ b/TMDbLibTests/ClientMovieTests.cs @@ -600,7 +600,7 @@ namespace TMDbLibTests await TMDbClient.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.MadMaxFuryRoad, false); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the movie is NOT favourited accountState = await TMDbClient.GetMovieAccountStateAsync(IdHelper.MadMaxFuryRoad); @@ -612,7 +612,7 @@ namespace TMDbLibTests await TMDbClient.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.MadMaxFuryRoad, true); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the movie IS favourited accountState = await TMDbClient.GetMovieAccountStateAsync(IdHelper.MadMaxFuryRoad); @@ -631,7 +631,7 @@ namespace TMDbLibTests await TMDbClient.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.MadMaxFuryRoad, false); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the movie is NOT watchlisted accountState = await TMDbClient.GetMovieAccountStateAsync(IdHelper.MadMaxFuryRoad); @@ -643,7 +643,7 @@ namespace TMDbLibTests await TMDbClient.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.MadMaxFuryRoad, true); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the movie IS watchlisted accountState = await TMDbClient.GetMovieAccountStateAsync(IdHelper.MadMaxFuryRoad); @@ -663,7 +663,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.MovieRemoveRatingAsync(IdHelper.MadMaxFuryRoad)); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); } // Test that the movie is NOT rated @@ -676,7 +676,7 @@ namespace TMDbLibTests await TMDbClient.MovieSetRatingAsync(IdHelper.MadMaxFuryRoad, 5); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the movie IS rated accountState = await TMDbClient.GetMovieAccountStateAsync(IdHelper.MadMaxFuryRoad); @@ -724,7 +724,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.MovieSetRatingAsync(IdHelper.Avatar, newRating)); // Allow TMDb to not cache our data - Thread.Sleep(2000); + await Task.Delay(2000); // Check if it worked Assert.Equal(newRating, (await TMDbClient.GetMovieAccountStateAsync(IdHelper.Avatar)).Rating); @@ -733,7 +733,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.MovieSetRatingAsync(IdHelper.Avatar, originalRating)); // Allow TMDb to not cache our data - Thread.Sleep(2000); + await Task.Delay(2000); // Check if it worked Assert.Equal(originalRating, (await TMDbClient.GetMovieAccountStateAsync(IdHelper.Avatar)).Rating); @@ -810,7 +810,7 @@ namespace TMDbLibTests await TMDbClient.MovieSetRatingAsync(IdHelper.TheDarkKnightRises, 5); // Allow TMDb to update cache - Thread.Sleep(2000); + await Task.Delay(2000); movie = await TMDbClient.GetMovieAsync(IdHelper.TheDarkKnightRises, MovieMethods.AccountStates); } diff --git a/TMDbLibTests/ClientTvEpisodeTests.cs b/TMDbLibTests/ClientTvEpisodeTests.cs index 3ec6bd5..de30705 100644 --- a/TMDbLibTests/ClientTvEpisodeTests.cs +++ b/TMDbLibTests/ClientTvEpisodeTests.cs @@ -56,7 +56,7 @@ namespace TMDbLibTests await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 5); // Allow TMDb to update cache - Thread.Sleep(2000); + await Task.Delay(2000); episode = await TMDbClient.GetTvEpisodeAsync(IdHelper.BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates); } @@ -165,7 +165,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1)); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); } // Test that the episode is NOT rated @@ -178,7 +178,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5)); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the episode IS rated accountState = await TMDbClient.GetTvEpisodeAccountStateAsync(IdHelper.BreakingBad, 1, 1); diff --git a/TMDbLibTests/ClientTvSeasonTests.cs b/TMDbLibTests/ClientTvSeasonTests.cs index bbb2deb..d02d01f 100644 --- a/TMDbLibTests/ClientTvSeasonTests.cs +++ b/TMDbLibTests/ClientTvSeasonTests.cs @@ -57,7 +57,7 @@ namespace TMDbLibTests await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 5); // Allow TMDb to update cache - Thread.Sleep(2000); + await Task.Delay(2000); season = await TMDbClient.GetTvSeasonAsync(IdHelper.BigBangTheory, 1, TvSeasonMethods.AccountStates); } @@ -151,7 +151,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 3, 3)); // Wait for TMDb to un-cache our value - Thread.Sleep(2000); + await Task.Delay(2000); // Fetch out the seasons state ResultContainer state = await TMDbClient.GetTvSeasonAccountStateAsync(IdHelper.BreakingBad, 1); @@ -167,7 +167,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 3)); // Wait for TMDb to un-cache our value - Thread.Sleep(2000); + await Task.Delay(2000); state = await TMDbClient.GetTvSeasonAccountStateAsync(IdHelper.BreakingBad, 1); Assert.NotNull(state); diff --git a/TMDbLibTests/ClientTvShowTests.cs b/TMDbLibTests/ClientTvShowTests.cs index 61b12e8..33c477d 100644 --- a/TMDbLibTests/ClientTvShowTests.cs +++ b/TMDbLibTests/ClientTvShowTests.cs @@ -192,7 +192,7 @@ namespace TMDbLibTests await TMDbClient.TvShowSetRatingAsync(IdHelper.BigBangTheory, 5); // Allow TMDb to update cache - Thread.Sleep(2000); + await Task.Delay(2000); show = await TMDbClient.GetTvShowAsync(IdHelper.BigBangTheory, TvShowMethods.AccountStates); } @@ -465,7 +465,7 @@ namespace TMDbLibTests await TMDbClient.AccountChangeFavoriteStatusAsync(MediaType.Tv, IdHelper.BreakingBad, false); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the movie is NOT favourited accountState = await TMDbClient.GetTvShowAccountStateAsync(IdHelper.BreakingBad); @@ -477,7 +477,7 @@ namespace TMDbLibTests await TMDbClient.AccountChangeFavoriteStatusAsync(MediaType.Tv, IdHelper.BreakingBad, true); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the movie IS favourited accountState = await TMDbClient.GetTvShowAccountStateAsync(IdHelper.BreakingBad); @@ -496,7 +496,7 @@ namespace TMDbLibTests await TMDbClient.AccountChangeWatchlistStatusAsync(MediaType.Tv, IdHelper.BreakingBad, false); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the movie is NOT watchlisted accountState = await TMDbClient.GetTvShowAccountStateAsync(IdHelper.BreakingBad); @@ -508,7 +508,7 @@ namespace TMDbLibTests await TMDbClient.AccountChangeWatchlistStatusAsync(MediaType.Tv, IdHelper.BreakingBad, true); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the movie IS watchlisted accountState = await TMDbClient.GetTvShowAccountStateAsync(IdHelper.BreakingBad); @@ -528,11 +528,11 @@ namespace TMDbLibTests Assert.True(await TMDbClient.TvShowRemoveRatingAsync(IdHelper.BreakingBad)); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); } // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the movie is NOT rated accountState = await TMDbClient.GetTvShowAccountStateAsync(IdHelper.BreakingBad); @@ -544,7 +544,7 @@ namespace TMDbLibTests await TMDbClient.TvShowSetRatingAsync(IdHelper.BreakingBad, 5); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the movie IS rated accountState = await TMDbClient.GetTvShowAccountStateAsync(IdHelper.BreakingBad); @@ -588,7 +588,7 @@ namespace TMDbLibTests Assert.True(await TMDbClient.TvShowRemoveRatingAsync(IdHelper.BreakingBad)); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); } // Test that the episode is NOT rated @@ -601,7 +601,7 @@ namespace TMDbLibTests await TMDbClient.TvShowSetRatingAsync(IdHelper.BreakingBad, 5); // Allow TMDb to cache our changes - Thread.Sleep(2000); + await Task.Delay(2000); // Test that the episode IS rated accountState = await TMDbClient.GetTvShowAccountStateAsync(IdHelper.BreakingBad);