public void MarkMovieAsUnwatchedIfMediaLibraryAvailable(List <MediaItem> databaseMovies, List <Movie> traktMovies, int expectedMoviesCount)
        {
            // Arrange
            IMediaPortalServices mediaPortalServices = GetMockMediaPortalServices(databaseMovies);
            ITraktClient         traktClient         = Substitute.For <ITraktClient>();

            traktClient.AddCollectionItems(Arg.Any <ITraktSyncCollectionPost>()).Returns(new TraktSyncCollectionPostResponse());
            traktClient.AddWatchedHistoryItems(Arg.Any <ITraktSyncHistoryPost>()).Returns(new TraktSyncHistoryPostResponse());
            TraktAuthorization authorization = Substitute.For <TraktAuthorization>();

            authorization.AccessToken = "ValidToken";
            traktClient.TraktAuthorization.Returns(authorization);
            ITraktCache traktCache = Substitute.For <ITraktCache>();

            traktCache.RefreshMoviesCache().Returns(new TraktMovies {
                UnWatched = traktMovies, Watched = new List <MovieWatched>(), Collected = new List <MovieCollected>()
            });
            IFileOperations         fileOperations         = Substitute.For <IFileOperations>();
            ILibrarySynchronization librarySynchronization = new LibrarySynchronization(mediaPortalServices, traktClient, traktCache, fileOperations);

            // Act
            TraktSyncMoviesResult result = librarySynchronization.SyncMovies();

            // Assert
            Assert.Equal(expectedMoviesCount, result.MarkedAsUnWatchedInLibrary);
        }
 public LibrarySynchronization(IMediaPortalServices mediaPortalServices, ITraktClient traktClient, ITraktCache traktCache, IFileOperations fileOperations)
 {
     _mediaPortalServices = mediaPortalServices;
     _traktClient         = traktClient;
     _traktCache          = traktCache;
     _fileOperations      = fileOperations;
 }
        public void AddWatchedEpisodeToTraktIfMediaLibraryAvailable(IList <MediaItem> databaseEpisodes, IList <EpisodeWatched> traktEpisodes, int?expectedEpisodesCount)
        {
            // Arrange
            IMediaPortalServices mediaPortalServices = GetMockMediaPortalServices(databaseEpisodes);
            ITraktClient         traktClient         = Substitute.For <ITraktClient>();

            traktClient.AddCollectionItems(Arg.Any <ITraktSyncCollectionPost>()).Returns(new TraktSyncCollectionPostResponse());
            traktClient.AddWatchedHistoryItems(Arg.Any <ITraktSyncHistoryPost>()).Returns(
                new TraktSyncHistoryPostResponse {
                Added = new TraktSyncPostResponseGroup {
                    Episodes = expectedEpisodesCount
                }
            });
            TraktAuthorization authorization = Substitute.For <TraktAuthorization>();

            authorization.AccessToken = "ValidToken";
            traktClient.TraktAuthorization.Returns(authorization);
            ITraktCache traktCache = Substitute.For <ITraktCache>();

            traktCache.RefreshSeriesCache().Returns(new TraktEpisodes {
                Watched = traktEpisodes, UnWatched = new List <Episode>(), Collected = new List <EpisodeCollected>()
            });
            IFileOperations         fileOperations         = Substitute.For <IFileOperations>();
            ILibrarySynchronization librarySynchronization = new LibrarySynchronization(mediaPortalServices, traktClient, traktCache, fileOperations);

            // Act
            TraktSyncEpisodesResult result = librarySynchronization.SyncSeries();

            // Assert
            Assert.Equal(expectedEpisodesCount, result.AddedToTraktWatchedHistory);
        }