public void TestVlcJobGetsAddedToCollection() { var file = TestUtilities.GetTestFile("NeedinYou2SecWav.wav"); var audioConfiguration = new AudioConfiguration { Format = AudioConfiguration.ConversionFormats.Mp3 }; var portAllocator = MockRepository.GenerateMock <IPortAllocator>(); portAllocator.Expect(x => x.NewPort()).Return(42); var job = new VlcAudioJob(audioConfiguration, portAllocator, MockRepository.GenerateMock <IStatusParser>(), MockRepository.GenerateMock <IVlcStatusSource>(), new TimeSouce(), MockRepository.GenerateMock <ILogger>()); Assert.AreEqual(VlcJob.JobState.NotStarted, job.State); job.InputFile = file; var expectedOutputFile = Path.Combine(TestUtilities.GetTestOutputDir(), "output.mp3"); job.OutputFile = new FileInfo(expectedOutputFile); var starter = MockRepository.GenerateMock <IVlcStarter>(); var instance = MockRepository.GenerateMock <IVlcInstance>(); starter.Expect(x => x.Start(Arg <string> .Is.Anything, Arg <FileInfo> .Is.Anything)).Return(instance); var driver = new VlcDriver(starter); TestUtilities.SetVlcExeLocationOnNonStandardWindowsEnvironments(driver); Assert.AreEqual(0, driver.JobBag.Count); Assert.AreEqual(VlcJob.JobState.NotStarted, job.State); driver.StartJob(job); Assert.AreEqual(1, driver.JobBag.Count); Assert.AreEqual(VlcJob.JobState.Started, job.State); instance.Raise(x => x.OnExited += null, instance, new EventArgs()); Assert.AreEqual(1, driver.JobBag.Count); }
static void Main() { #region This region is only for use in this console example as ending the console will leave VLC running handler = ConsoleEventCallback; var osver = Environment.OSVersion; switch (osver.Platform) { case PlatformID.Win32NT: SetConsoleCtrlHandler(handler, true); break; } #endregion var input = new FileInfo(@"c:\Temp\inputVideo.avi"); var output = new FileInfo(@"c:\Temp\outputVideo.mpg"); if (!input.Exists) { throw new FileNotFoundException("Example app needs a file to convert", input.FullName); } var driver = new VlcDriver(); //driver.VlcExePath = new FileInfo("/usr/bin/vlc"); - Only on Non Windows environments Job = driver.CreateVideoJob(); Job.InputFile = input; Job.OutputFile = output; Job.VideoConfiguration.Format = VideoConfiguration.VlcVideoFormat.Mpeg2; Job.AudioConfiguration.Format = AudioConfiguration.ConversionFormats.Mpg; driver.StartJob(Job); while (Job.State != VlcJob.JobState.Finished) { Job.UpdateProgress(); Console.Clear(); Console.SetCursorPosition(0, 0); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("{0}% Complete. Remaining {1}", string.Format("{0:0.0#}", Job.PercentComplete * 100), Job.EstimatedTimeToCompletion.ToString(@"h\h\:m\m\:s\s", System.Globalization.CultureInfo.InvariantCulture)); Thread.Sleep(1000); } }
public void TestVlcWav2Mp3JobActuallyGetsDone() { var file = TestUtilities.GetTestFile("NeedinYou2SecWav.wav"); var audioConfiguration = new AudioConfiguration { Format = AudioConfiguration.ConversionFormats.Mp3 }; var portAllocator = MockRepository.GenerateMock <IPortAllocator>(); portAllocator.Expect(x => x.NewPort()).Return(42); var job = new VlcAudioJob(audioConfiguration, portAllocator, MockRepository.GenerateMock <IStatusParser>(), MockRepository.GenerateMock <IVlcStatusSource>(), new TimeSouce(), MockRepository.GenerateMock <ILogger>()); Assert.AreEqual(VlcJob.JobState.NotStarted, job.State); job.InputFile = file; var expectedOutputFile = Path.Combine(TestUtilities.GetTestOutputDir(), "output.mp3"); job.OutputFile = new FileInfo(expectedOutputFile); var driver = new VlcDriver(new VlcStarter(MockRepository.GenerateMock <ILogger>())); TestUtilities.SetVlcExeLocationOnNonStandardWindowsEnvironments(driver); Assert.IsFalse(job.OutputFile.Exists); driver.StartJob(job); Assert.AreEqual(1, driver.JobBag.Count); Assert.IsNotNull(job.Instance); Assert.IsNotNull(job.Instance.Process); Assert.AreEqual(VlcJob.JobState.Started, job.State); job.Instance.Process.WaitForExit(); SleepToAllowEventHandler(); Assert.AreEqual(VlcJob.JobState.Finished, job.State); var newFileInfo = new FileInfo(job.OutputFile.FullName); Assert.IsTrue(newFileInfo.Exists); Assert.That(newFileInfo.Length, Is.EqualTo(48901).Within(AllowedOutputFileComparePercentage).Percent); }