public void TestVlcMp32WavJobActuallyGetsDone()
        {
            var file = TestUtilities.GetTestFile("NeedinYou2SecWavMp3128.mp3");
            var audioConfiguration = new AudioConfiguration
            {
                Format = AudioConfiguration.ConversionFormats.Wav
            };

            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(), "output2.wav");
            job.OutputFile = new FileInfo(expectedOutputFile);

            var driver = new VlcDriver(new VlcStarter(MockRepository.GenerateMock<ILogger>()));
            TestUtilities.SetVlcExeLocationOnNonStandardWindowsEnvironments(driver);
            Assert.IsFalse(job.OutputFile.Exists, "output file already exists, cannot run test");
            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, "Job state was not set to finished afterwards");
            var newFileInfo = new FileInfo(job.OutputFile.FullName);
            Assert.IsTrue(newFileInfo.Exists);
            Assert.That(newFileInfo.Length, Is.EqualTo(368684).Within(AllowedOutputFileComparePercentage).Percent);
        }
        public void TestAudioJobSimpleMp3ToWavConversionUsingDefaults()
        {
            var audioConfiguration = new AudioConfiguration
            {
                Format = AudioConfiguration.ConversionFormats.Wav
            };

            var arguments = audioConfiguration.GetPartArguments();
            const string expectedArguments = "acodec=s16l,ab=128,channels=2,samplerate=44100";
            Assert.AreEqual(expectedArguments, arguments);
        }
        public void TestAudioJobSimpleWavToMp3ConversionChangeChannelsTo1()
        {
            var audioConfiguration = new AudioConfiguration
            {
                Format = AudioConfiguration.ConversionFormats.Mp3,
                Channels = 1
            };

            var arguments = audioConfiguration.GetPartArguments();
            const string expectedArguments = "acodec=mp3,ab=192,channels=1,samplerate=44100";
            Assert.AreEqual(expectedArguments, arguments);
        }
        public void TestAudioJobSimpleWavToMp3ConversionChangeBitrateTo64()
        {
            var audioConfiguration = new AudioConfiguration
            {
                Format = AudioConfiguration.ConversionFormats.Mp3,
                AudioBitrateInkbps = 64
            };

            var arguments = audioConfiguration.GetPartArguments();
            const string expectedArguments = "acodec=mp3,ab=64,channels=2,samplerate=44100";
            Assert.AreEqual(expectedArguments, arguments);
        }
        public void TestConversionWithoutAudio()
        {
            var audioConfiguration = new AudioConfiguration
            {
                Format = AudioConfiguration.ConversionFormats.None
            };

            var arguments = audioConfiguration.GetPartArguments();
            const string expectedArguments = "acodec=none";
            Assert.AreEqual(expectedArguments, arguments);
        }
Beispiel #6
0
        public void TestWeGetJobStateChangedEventWhenConversionEnds()
        {
            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);
            var eventHandlerWasCalled = false;
            driver.OnJobStateChange += (source, args) =>
            {
                eventHandlerWasCalled = true;
                Assert.AreEqual(job, args.Job);
            };
            instance.Raise(x => x.OnExited += null, instance, new EventArgs());
            Assert.IsTrue(eventHandlerWasCalled);
        }
Beispiel #7
0
 protected override string GetSpecificJobTypeArguments()
 {
     return(string.Format("vcodec=none,{0}", AudioConfiguration.GetPartArguments()));
 }
Beispiel #8
0
 protected override string GetSpecificJobTypeArguments()
 {
     return(string.Format("{0},{1}", VideoConfiguration.GetPartArguments(), AudioConfiguration.GetPartArguments()));
 }