public void TestDvdEpisodesDetected() { var rootLocation = MockFolderMediaLocation.CreateMockLocation( @" |Root |TV |Simpsons |Season 1 |1 |video_ts a.vob |2 a.vob |3 a.vob "); var rootFolder = Kernel.Instance.GetItem <MediaBrowser.Library.Entities.Folder>(rootLocation); Assert.IsNotNull(rootFolder); var tv = rootFolder.Children[0] as IFolder; var simpsons = tv.Children[0] as IFolder; var season1 = simpsons.Children[0] as IFolder; foreach (var item in season1.Children) { Assert.AreEqual(typeof(Episode), item.GetType()); } }
public void TestDVDResolution() { var resolver = CreateResolver(); var root = MockFolderMediaLocation.CreateMockLocation( @" |Movies |Fight Club |video_ts movie.vob |Spandax movie.vob "); BaseItemFactory factory; IEnumerable <InitializationParameter> setup; resolver.ResolveEntity(root, out factory, out setup); Assert.AreEqual(typeof(MediaBrowser.Library.Entities.Folder), factory.EntityType); foreach (var child in root.Children) { resolver.ResolveEntity(child, out factory, out setup); Assert.AreEqual(typeof(Movie), factory.EntityType); Assert.AreEqual(MediaType.DVD, (setup.First() as MediaTypeInitializationParameter).MediaType); } }
public void TestLibraryNavigation() { var rootLocation = MockFolderMediaLocation.CreateMockLocation( @" |Root |Doco |movie1 a.avi b.avi |movie2 a.avi movie3.avi movie4.avi movie5.avi "); var rootFolder = Kernel.Instance.GetItem <MediaBrowser.Library.Entities.Folder>(rootLocation); Assert.IsNotNull(rootFolder); Assert.AreEqual(4, rootFolder.Children.Count()); foreach (var item in rootFolder.Children.Skip(1)) { Assert.AreEqual(typeof(Movie), item.GetType()); } Assert.AreEqual("movie3", rootFolder.Children.ElementAt(1).Name); }
public void TestChildValidation() { var rootLocation = MockFolderMediaLocation.CreateMockLocation( @" |Root movie3.avi movie4.avi movie5.avi "); var rootLocationNew = MockFolderMediaLocation.CreateMockLocation( @" |Root movie3.avi movie4.avi movie5.avi movie6.avi "); var rootFolder = Kernel.Instance.GetItem(rootLocation) as MediaBrowser.Library.Entities.Folder; rootFolder.Id = Guid.NewGuid(); Assert.AreEqual(3, rootFolder.Children.Count()); var oldFactory = Kernel.Instance.MediaLocationFactory; Kernel.Instance.MediaLocationFactory = new MockMediaLocationFactory(rootLocationNew); rootFolder.ValidateChildren(); Assert.AreEqual(4, rootFolder.Children.Count()); Kernel.Instance.MediaLocationFactory = oldFactory; }
public void TestMetadataFoldersShouldBeIgnored() { var resolver = CreateResolver(); var root = MockFolderMediaLocation.CreateMockLocation( @" |TV |.metaData metadata.xml metadata2.xml |metadata metadata.xml metadata2.xml a.avi b.avi c.avi " ); BaseItemFactory factory; IEnumerable <InitializationParameter> setup; resolver.ResolveEntity(root.Children[0], out factory, out setup); Assert.IsNull(factory); resolver.ResolveEntity(root.Children[1], out factory, out setup); Assert.IsNull(factory); }
public void IntegrationTest() { var oldRepository = Kernel.Instance.ItemRepository; try { // Swap out item caching Kernel.Instance.ItemRepository = new DummyItemRepository(); var folder = MockFolderMediaLocation.CreateMockLocation( @" |Weeds |Season 1 01.avi 02.avi 03.avi "); var root = Kernel.Instance.GetItem <Folder>(folder); Series series = (Series)root; Season season = (Season)root.Children[0]; Episode episode = (Episode)season.Children[0]; series.RefreshMetadata(); Assert.AreEqual("74845", series.TVDBSeriesId); season.RefreshMetadata(); episode.RefreshMetadata(); Assert.AreEqual("1", episode.EpisodeNumber); } finally { Kernel.Instance.ItemRepository = oldRepository; } }
public void TestRecusiveMovieResolution() { var resolver = CreateResolver(); var movie = MockFolderMediaLocation.CreateMockLocation(@" |Rushmore |part 1 a.avi |part 2 b.avi "); Assert.AreEqual(resolver.ResolveType(movie), typeof(Movie)); }
public void TestISOResolution() { var rootLocation = MockFolderMediaLocation.CreateMockLocation( @" |Root Rocky.iso Rambo.iso "); var rootFolder = Kernel.Instance.GetItem <MediaBrowser.Library.Entities.Folder>(rootLocation); Assert.AreEqual(2, rootFolder.Children.Count()); Assert.AreEqual(MediaType.ISO, (rootFolder.Children[0] as Video).MediaType); Assert.AreEqual(MediaType.ISO, (rootFolder.Children[1] as Video).MediaType); }
public void TestNestedMoviesAreAlwaysTreatedAsBoxSets() { var resolver = CreateResolver(); var movie = MockFolderMediaLocation.CreateMockLocation(@" |Star Wars |part 1 a.avi mymovies.xml |part 2 b.avi mymovies.xml "); Assert.AreEqual(resolver.ResolveType(movie), typeof(Folder)); }
public void TestRubbishFilesToNotKillResolution() { var resolver = CreateResolver(); var movie = MockFolderMediaLocation.CreateMockLocation(@" |Star Wars rubbish.bla bla.jpg folder.jpg |part 1 a.avi |part 2 b.avi "); Assert.AreEqual(resolver.ResolveType(movie), typeof(Movie)); }
public void TestMixedIsoAndAvi() { var resolver = CreateResolver(); var movie = MockFolderMediaLocation.CreateMockLocation(@" |Star Wars Trilogy rubbish.bla |Volume 1 a.iso |Volume 2 a.avi |Volume 3 b.avi "); Assert.AreEqual(resolver.ResolveType(movie), typeof(Folder)); Assert.AreEqual(resolver.ResolveType(movie.Children[1]), typeof(Movie)); Assert.AreEqual(resolver.ResolveType(movie.Children[2]), typeof(Movie)); Assert.AreEqual(resolver.ResolveType(movie.Children[3]), typeof(Movie)); }
public void TestMixedBluRayAndAvi() { var resolver = CreateResolver(); var movie = MockFolderMediaLocation.CreateMockLocation(@" |Star Wars Trilogy rubbish.bla |Volume 1 |BDMV MOVIEOBJ.BDM |Volume 2 a.avi |Volume 3 b.avi "); Assert.AreEqual(typeof(Folder), resolver.ResolveType(movie)); Assert.AreEqual(typeof(Movie), resolver.ResolveType(movie.Children[1])); Assert.AreEqual(typeof(Movie), resolver.ResolveType(movie.Children[2])); Assert.AreEqual(typeof(Movie), resolver.ResolveType(movie.Children[3])); }
public void TestThatUniqueIdChangesWhenTypeChanges() { var root = MockFolderMediaLocation.CreateMockLocation(@" |Lib movie.avi "); var id = Kernel.Instance.GetItem(root).Id; Assert.AreEqual(id, Kernel.Instance.GetItem(root).Id); root = MockFolderMediaLocation.CreateMockLocation(@" |Lib movie.avi movie2.avi movie3.avi "); var id2 = Kernel.Instance.GetItem(root).Id; Assert.AreNotEqual(id, id2); }
public void TestChildCaching() { var rootLocation = MockFolderMediaLocation.CreateMockLocation( @" |Root movie3.avi movie4.avi movie5.avi "); var rootFolder = Kernel.Instance.GetItem <MediaBrowser.Library.Entities.Folder>(rootLocation); rootFolder.Id = Guid.NewGuid(); Assert.AreEqual(3, rootFolder.Children.Count()); var cached = new MediaBrowser.Library.Entities.Folder(); cached.Id = rootFolder.Id; Assert.AreEqual(3, cached.Children.Count()); }