public void Should_ThrowPathNotFoundException_When_WatchedEpisodesFileNotFound() { // Arrange IMediaPortalServices mediaPortalServices = Substitute.For <IMediaPortalServices>(); string savedEpisodesPath = Path.Combine(FakePath, FileName.WatchedEpisodes.Value); IFileOperations fileOperations = Substitute.For <IFileOperations>(); fileOperations.FileExists(savedEpisodesPath).Returns(false); IMoverOperations operations = new MoverOperations(mediaPortalServices, fileOperations); // Act & Assert Assert.Throws <PathNotFoundException>(() => operations.RestoreWatchedSeries(FakePath)); }
public void Should_MarkFourEpisodesAsWatched_When_FourEpisodesRestored() { // Arrange IMediaPortalServices mediaPortalServices = Substitute.For <IMediaPortalServices>(); IContentDirectory contentDirectory = Substitute.For <IContentDirectory>(); IList <MediaItem> databaseMediaItems = new List <MediaItem> { new MockedDatabaseEpisode("272127", 1, new List <int> { 7, 8 }, 0).Episode, new MockedDatabaseEpisode("317653", 1, new List <int> { 1 }, 0).Episode, new MockedDatabaseEpisode("317653", 1, new List <int> { 2 }, 0).Episode, new MockedDatabaseEpisode("275271", 2, new List <int> { 11, 12 }, 0).Episode }; contentDirectory.SearchAsync(Arg.Any <MediaItemQuery>(), true, null, false).Returns(databaseMediaItems); mediaPortalServices.GetServerConnectionManager().ContentDirectory.Returns(contentDirectory); mediaPortalServices.MarkAsWatched(Arg.Any <MediaItem>()).Returns(true); string savedEpisodesPath = Path.Combine(FakePath, FileName.WatchedEpisodes.Value); IFileOperations fileOperations = Substitute.For <IFileOperations>(); fileOperations.FileExists(savedEpisodesPath).Returns(true); string watchedEpisodesJson = "[{\"show_imdb\":\"tt6682754\",\"show_tvdb\":317653,\"show_title\":\"Je-an-Claude Van Johnson\",\"season\":1,\"number\":1}," + "{\"show_imdb\":\"tt3155320\",\"show_tvdb\":272127,\"show_title\":\"Extant\",\"season\":1,\"number\":7}," + "{\"show_imdb\":\"tt3155320\",\"show_tvdb\":272127,\"show_title\":\"Extant\",\"season\":1,\"number\":8}," + "{\"show_imdb\":\"tt6682754\",\"show_tvdb\":317653,\"show_title\":\"Jean-Claude Van Johnson\",\"season\":1,\"number\":2}]"; fileOperations.FileReadAllText(savedEpisodesPath).Returns(watchedEpisodesJson); IMoverOperations operations = new MoverOperations(mediaPortalServices, fileOperations); // Act RestoreResult result = operations.RestoreWatchedSeries(FakePath); // Assert Assert.Equal(4, result.MarkedWatchedCount); Assert.Equal(4, result.SavedWatchedCount); }