public void EnableTraktScrobbleHandlerWhenUserChanged()
        {
            // Arrange
            IMediaPortalServices mediaPortalServices = Substitute.For <IMediaPortalServices>();

            mediaPortalServices.GetTraktUserHomePath().Returns(DataPath);
            TraktPluginSettings settings = new TraktPluginSettings
            {
                IsScrobbleEnabled = false
            };
            ITraktSettingsChangeWatcher settingsChangeWatcher = Substitute.For <ITraktSettingsChangeWatcher>();

            settingsChangeWatcher.TraktSettings.Returns(settings);
            mediaPortalServices.GetTraktSettingsWatcher().Returns(settingsChangeWatcher);

            IUserMessageHandler userMessageHandler = Substitute.For <IUserMessageHandler>();

            mediaPortalServices.GetUserMessageHandler().Returns(userMessageHandler);

            ITraktClient    traktClient    = Substitute.For <ITraktClient>();
            IFileOperations fileOperations = Substitute.For <IFileOperations>();

            fileOperations.FileExists(Path.Combine(DataPath, FileName.Authorization.Value)).Returns(true);

            TraktScrobbleHandlerManager traktScrobbleHandler = new TraktScrobbleHandlerManager(mediaPortalServices, traktClient, fileOperations);

            // Act
            settings.IsScrobbleEnabled           = true;
            userMessageHandler.UserChangedProxy += Raise.Event();

            // Assert
            Assert.True(traktScrobbleHandler.IsActive);
        }
Esempio n. 2
0
 public TraktScrobbleHandlerManager(IMediaPortalServices mediaPortalServices, ITraktClient traktClient, IFileOperations fileOperations)
 {
     _mediaPortalServices = mediaPortalServices;
     _traktClient         = traktClient;
     _fileOperations      = fileOperations;
     _mediaPortalServices.GetTraktSettingsWatcher().TraktSettingsChanged += ConfigureHandler;
     _mediaPortalServices.GetUserMessageHandler().UserChangedProxy       += ConfigureHandler;
     ConfigureHandler();
 }
 public TraktSyncHandlerManager(IMediaPortalServices mediaPortalServices, ILibrarySynchronization librarySynchronization, IFileOperations fileOperations)
 {
     _mediaPortalServices    = mediaPortalServices;
     _fileOperations         = fileOperations;
     _librarySynchronization = librarySynchronization;
     _mediaPortalServices.GetTraktSettingsWatcher().TraktSettingsChanged += ConfigureHandler;
     _mediaPortalServices.GetUserMessageHandler().UserChangedProxy       += ConfigureHandler;
     ConfigureHandler();
 }