public void AutoRenameTest() { var fileInfo = new FileInfo( Path.Combine( settings.Object.Value.MediaLibraryPath, "TV Shows", "The Big Bang Theory", "Season 01", "The Big Bang Theory - S10E01 - The Conjugal Conjecture.mp4")); fileInfo.Directory.Create(); File.WriteAllText(fileInfo.FullName, "abcd"); // directory var service = new MediaLibraryService(logger.Object, settings.Object, mover.Object, filebot.Object); var item = new PlainMediaItem(fileInfo.Directory, settings.Object.Value.MediaLibraryPath); Assert.Null(service.AutoRename(item)); mover.Setup(x => x.MoveVideoFile(fileInfo.FullName)).Returns(new List <FileSystemInfo>()); service = new MediaLibraryService(logger.Object, settings.Object, mover.Object, filebot.Object); service.AutoRename(new PlainMediaItem(fileInfo, settings.Object.Value.MediaLibraryPath)); mover.Verify(x => x.MoveVideoFile(It.IsAny <string>()), Times.Once); }
public void SetUp() { // Custom options passed to DbContext var options = new DbContextOptionsBuilder <MediaLibraryDbContext>() .UseSqlite(_connection) .Options; // Instantiate the custom context var context = new MediaLibraryDbContext(options); // Instantiate the class to test _toTest = new MediaLibraryService(context); }
public void GetSubtitlesTest() { var fileInfo = new FileInfo( Path.Combine( settings.Object.Value.MediaLibraryPath, "TV Shows", "The Big Bang Theory", "Season 01", "The Big Bang Theory - S10E01 - The Conjugal Conjecture.mp4")); fileInfo.Directory.Create(); File.WriteAllText(fileInfo.FullName, "abcd"); // directory var service = new MediaLibraryService(logger.Object, settings.Object, mover.Object, filebot.Object); var item = new PlainMediaItem(fileInfo.Directory, settings.Object.Value.MediaLibraryPath); Assert.Null(service.GetSubtitles(item, "eng")); // no subtitles found string _; filebot.Setup(x => x.GetSubtitles(It.IsAny <string>(), out _, It.IsAny <string>(), It.IsAny <bool>())).Returns(false); service = new MediaLibraryService(logger.Object, settings.Object, mover.Object, filebot.Object); item = new PlainMediaItem(fileInfo, settings.Object.Value.MediaLibraryPath); Assert.Null(service.GetSubtitles(item, "eng")); // subtitles found var srtPath = Path.Combine( Path.GetDirectoryName(fileInfo.FullName), Path.GetFileNameWithoutExtension(fileInfo.Name) + ".eng.srt"); File.WriteAllText(srtPath, "aaa"); filebot.Setup(x => x.GetSubtitles(It.IsAny <string>(), out srtPath, It.IsAny <string>(), It.IsAny <bool>())).Returns(true); service = new MediaLibraryService(logger.Object, settings.Object, mover.Object, filebot.Object); item = new PlainMediaItem(fileInfo, settings.Object.Value.MediaLibraryPath); var srtItem = service.GetSubtitles(item, "eng"); Assert.AreEqual(3, srtItem.Size); Assert.AreEqual("TV Shows/The Big Bang Theory/Season 01", srtItem.Parent); }
public void SetUp() { // In-memory database only exists while the connection is open _connection = new SqliteConnection("DataSource=:memory:"); _connection.Open(); // Custom options passed to DbContext var options = new DbContextOptionsBuilder <MediaLibraryDbContext>() .UseSqlite(_connection) .Options; // Instantiate the custom context var context = new MediaLibraryDbContext(options); // Instantiate the class to test _toTest = new MediaLibraryService(context); // Create the schema in the database context.Database.EnsureCreated(); }
public static void ClassSetup(TestContext testContext) { // In-memory database only exists while the connection is open _connection = new SqliteConnection("DataSource=:memory:"); _connection.Open(); // Custom options passed to DbContext var options = new DbContextOptionsBuilder <MediaLibraryDbContext>() .UseSqlite(_connection) .Options; // Instantiate the custom context var context = new MediaLibraryDbContext(options); // Instantiate the class to test var service = new MediaLibraryService(context); // Create the schema in the database context.Database.EnsureCreated(); // Add a movie service.Add( new Movie( "My movie", @"D:\repo\Something.stuff", "2019-12-31") ); // Add another movie service.Add( new Movie( "My movie 2", @"D:\repo\Something2.stuff", "2020-12-31") ); }