Exemplo n.º 1
0
        public void CleanUpCollectedMoviesAtTrakt()
        {
            // Arrange
            ILogger      logger      = Substitute.For <ILogger>();
            ITraktClient traktClient = new TraktClientProxy(ApplicationId, SecretId, logger);

            ValidateAuthorization(traktClient, new FileOperations());
            IEnumerable <ITraktCollectionMovie>   collectedMovies      = traktClient.GetCollectedMovies();
            IList <ITraktSyncCollectionPostMovie> collectionPostMovies = new List <ITraktSyncCollectionPostMovie>();

            foreach (ITraktCollectionMovie traktCollectionMovie in collectedMovies)
            {
                collectionPostMovies.Add(new TraktSyncCollectionPostMovie
                {
                    // Metadata = traktCollectionMovie.Metadata,
                    Ids   = traktCollectionMovie.Movie.Ids,
                    Year  = traktCollectionMovie.Movie.Year,
                    Title = traktCollectionMovie.Movie.Title
                });
            }

            // Act
            ITraktSyncCollectionRemovePostResponse response = traktClient.RemoveCollectionItems(new TraktSyncCollectionPost {
                Movies = collectionPostMovies
            });

            // Assert
            Assert.Equal(collectedMovies.Count(), response.Deleted.Movies);
        }
Exemplo n.º 2
0
        public void CleanUpCollectedShowAttrakt()
        {
            // Arrange
            ILogger      logger      = Substitute.For <ILogger>();
            ITraktClient traktClient = new TraktClientProxy(ApplicationId, SecretId, logger);

            ValidateAuthorization(traktClient, new FileOperations());
            IEnumerable <ITraktCollectionShow>   collectionShows     = traktClient.GetCollectedShows();
            IList <ITraktSyncCollectionPostShow> collectionPostShows = new List <ITraktSyncCollectionPostShow>();

            foreach (ITraktCollectionShow traktSyncCollectionPostShow in collectionShows)
            {
                collectionPostShows.Add(new TraktSyncCollectionPostShow
                {
                    Ids = traktSyncCollectionPostShow.Show.Ids
                });
            }

            // Act
            ITraktSyncCollectionRemovePostResponse response = traktClient.RemoveCollectionItems(new TraktSyncCollectionPost {
                Shows = collectionPostShows
            });

            Assert.NotNull(response);
        }
        public async Task Test_TraktSyncModule_RemoveCollectionItems()
        {
            string postJson = await TestUtility.SerializeObject(RemoveCollectionItemsPost);

            postJson.Should().NotBeNullOrEmpty();

            TraktClient client = TestUtility.GetOAuthMockClient(REMOVE_COLLECTION_ITEMS_URI, postJson, COLLECTION_REMOVE_POST_RESPONSE_JSON);
            TraktResponse <ITraktSyncCollectionRemovePostResponse> response = await client.Sync.RemoveCollectionItemsAsync(RemoveCollectionItemsPost);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull();

            ITraktSyncCollectionRemovePostResponse responseValue = response.Value;

            responseValue.Deleted.Should().NotBeNull();
            responseValue.Deleted.Movies.Should().Be(1);
            responseValue.Deleted.Episodes.Should().Be(12);
            responseValue.Deleted.Shows.Should().NotHaveValue();
            responseValue.Deleted.Seasons.Should().NotHaveValue();

            responseValue.NotFound.Should().NotBeNull();
            responseValue.NotFound.Movies.Should().NotBeNull().And.HaveCount(1);

            ITraktPostResponseNotFoundMovie[] movies = responseValue.NotFound.Movies.ToArray();

            movies[0].Ids.Should().NotBeNull();
            movies[0].Ids.Trakt.Should().Be(0);
            movies[0].Ids.Slug.Should().BeNullOrEmpty();
            movies[0].Ids.Imdb.Should().Be("tt0000111");
            movies[0].Ids.Tmdb.Should().BeNull();

            responseValue.NotFound.Shows.Should().NotBeNull().And.BeEmpty();
            responseValue.NotFound.Seasons.Should().NotBeNull().And.BeEmpty();
            responseValue.NotFound.Episodes.Should().NotBeNull().And.BeEmpty();
        }