public void StartScrobble(TraktPluginSettings settings, MediaItem mediaItem, ITraktClient traktClient, ITraktNotification notification)
        {
            // Arrange
            IMediaPortalServices mediaPortalServices = Substitute.For <IMediaPortalServices>();

            mediaPortalServices.GetTraktUserHomePath().Returns(DataPath);
            SetSettings(mediaPortalServices, settings);
            SetPlayerAndContentDirForMovie(mediaPortalServices, mediaItem);

            IAsynchronousMessageQueue messageQueue = GetMockedMsgQueue(mediaPortalServices);

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

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

            TraktScrobbleHandlerManager      traktScrobbleHandler = new TraktScrobbleHandlerManager(mediaPortalServices, traktClient, fileOperations);
            TraktScrobbleStartedNotification expectedNotification = (TraktScrobbleStartedNotification)notification;

            // Act
            // start the player
            messageQueue.MessageReceivedProxy += Raise.Event <MessageReceivedHandler>(new AsynchronousMessageQueue(new object(), new[] { "PlayerManager" }),
                                                                                      GetSystemMessageForMessageType(PlayerManagerMessaging.MessageType.PlayerStarted));

            // Assert
            mediaPortalServices.GetTraktNotificationModel().Received()
            .ShowNotification(Arg.Is <TraktScrobbleStartedNotification>(x => x.IsSuccess == expectedNotification.IsSuccess &&
                                                                        x.Message == expectedNotification.Message &&
                                                                        x.ActionType == expectedNotification.ActionType &&
                                                                        x.Progress == expectedNotification.Progress &&
                                                                        x.SuperLayerScreenName == expectedNotification.SuperLayerScreenName),
                              Arg.Any <TimeSpan>());
        }
Exemple #2
0
        public void ShouldSyncLibraryWhenShareImportCompletedIsWithSuccess()
        {
            // Arrange
            IMediaPortalServices mediaPortalServices = Substitute.For <IMediaPortalServices>();

            mediaPortalServices.GetTraktUserHomePath().Returns(DataPath);
            SetSettings(mediaPortalServices, new TraktPluginSettings {
                IsAutomaticLibrarySyncEnabled = true, ShowAutomaticSyncNotifications = true
            });

            IAsynchronousMessageQueue messageQueue = GetMockedMsgQueue(mediaPortalServices);

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

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

            ILibrarySynchronization librarySynchronization = Substitute.For <ILibrarySynchronization>();

            librarySynchronization.SyncMovies().Returns(new TraktSyncMoviesResult());
            librarySynchronization.SyncSeries().Returns(new TraktSyncEpisodesResult());

            TraktSyncHandlerManager traktScrobbleHandler = new TraktSyncHandlerManager(mediaPortalServices, librarySynchronization, fileOperations);

            // Act
            // send share import completed message
            messageQueue.MessageReceivedProxy += Raise.Event <MessageReceivedHandler>(new AsynchronousMessageQueue(new object(), new[] { "ContentDirectory" }),
                                                                                      GetSystemMessageForMessageType(ContentDirectoryMessaging.MessageType.ShareImportCompleted));

            // Assert
            mediaPortalServices.GetTraktNotificationModel().Received().ShowNotification(Arg.Any <TraktSyncLibrarySuccessNotification>(), Arg.Any <TimeSpan>());
        }
Exemple #3
0
 private void ShowNotification(ITraktNotification notification, TimeSpan duration)
 {
     _mediaPortalServices.GetTraktNotificationModel().ShowNotification(notification, duration);
 }