static void Main(string[] args) { ILog log = new ConsoleLog(); IFileSystem fileSystem = new FileSystem(); IMediaRepository repository = new DbMediaRepository(new EntityFrameworkSexContext()); IMediaFactory extractor = new MediaInfoDotNetMediaFactory(); IFileSystemObserver observer = new FileSystemObserver(@"\\Etrayz\public\Video\Otros"); MediaWatcher watcher = new MediaWatcher(fileSystem, repository, extractor, observer, log); watcher.Synchronize(@"\\Etrayz\public\Video\Otros"); watcher.Watch(); }
public void TestMethod1() { ILog log = new ConsoleLog(); IFileSystem fileSystem = new FileSystem(); IMediaRepository repository = new MemoryMediaRepository(); IMediaFactory extractor = new MediaInfoDotNetMediaFactory(); IFileSystemObserver observer = new FileSystemObserver(@"\\Etrayz\public\Video\Otros"); MediaWatcher watcher = new MediaWatcher(fileSystem, repository, extractor, observer, log); watcher.Synchronize(@"\\Etrayz\public\Video\Otros"); Assert.IsTrue(repository.ContainsFile("")); }
public async Task AddToUserWatchlistAsync(string userId, string mediaId, WatchType watchType) { var watcher = this.watchRepository.All() .FirstOrDefault(x => x.UserId == userId && x.MediaId == mediaId); if (watcher == null) { watcher = new MediaWatcher() { UserId = userId, MediaId = mediaId, }; await this.watchRepository.AddAsync(watcher); } watcher.WatchType = watchType; await this.watchRepository.SaveChangesAsync(); }
public void GivenNoFile_WhenWatching_AndAddingFiles_GetsThemIntoRepository() { const string audioFileName = "video.mp3"; const string videoFileName = "video.mp4"; ILog log = new ConsoleLog(); IFileSystem fileSystem = new FakeFileSystem(); IMediaRepository repository = new MemoryMediaRepository(); IMediaFactory extractor = A.Fake <IMediaFactory>(); A.CallTo(() => extractor.BuildFromFile(audioFileName)).Returns(new NonMedia()); A.CallTo(() => extractor.BuildFromFile(videoFileName)).Returns(new Video(videoFileName, 340, TimeSpan.Zero, 640, 320)); IFileSystemObserver observer = new FakeFileSystemObserver(fileSystem); MediaWatcher watcher = new MediaWatcher(fileSystem, repository, extractor, observer, log); watcher.Watch(); fileSystem.File.Create(audioFileName); fileSystem.File.Create(videoFileName); Assert.IsTrue(repository.ContainsFile(videoFileName)); }