コード例 #1
0
        public void MkvConvertor_ValidFilePath_SuccessObjectCreated() 
        { 
            // Arrange
            var file = _filePath + "test1.mkv";

            // Act
            var mkvConvertor = new MkvConvertor(file);

            // Assert
            Assert.IsNotNull(mkvConvertor);
        }
コード例 #2
0
        public void Convert_ValidDestinationPath_SuccessDestinationFileCreated()
        {
            // Arrange
            var file = _filePath + "test1.mkv";
            var destinationFile = file + ".mp4";
            var mkvConvertor = new MkvConvertor(file);

            // Act
            mkvConvertor.Convert(destinationFile);

            // Assert
            Assert.IsNotNull(mkvConvertor);
            Assert.IsTrue(System.IO.File.Exists(destinationFile));
        }
コード例 #3
0
        public void Convert_ValidDestinationPathFileLocked_FailureNoFileCreated()
        {
            // Arrange
            var file = _filePath + "test1.mkv";
            var destinationFile = file + ".mp4";
            var mkvConvertor1 = new MkvConvertor(file);

            // Act
            mkvConvertor1.Convert(destinationFile);
            mkvConvertor1.Convert(destinationFile);

            // Assert
            Assert.IsNotNull(mkvConvertor1);
            Assert.IsFalse(System.IO.File.Exists(destinationFile));
        } 
コード例 #4
0
        private void TimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            if (!IODirectory.Exists(_options.DirectoryPath)) 
                return;

            var mkvFiles = IODirectory.GetFiles(
                _options.DirectoryPath, 
                "*.mkv", 
                SearchOption.AllDirectories);

            Parallel.ForEach(mkvFiles, file =>
            {
                var mkvConvertor = new MkvConvertor(file);
                var destinationPath = string.Format("{0}.MP4", file);

                DirectoryMonitorLog.LogToEventViewer(string.Format("Processing File: {0}", file));
                mkvConvertor.Convert(destinationPath);
                DirectoryMonitorLog.LogToEventViewer(string.Format("Processing File Completed: {0}", file));

                MoveFileToFinishedDirectory(file);
            });
        }