public void SettingsCollection_MergeRange()
        {
            var startAtDefault           = new SeekPositionInput(2);
            var vcodecDefault            = new CodecVideo(VideoCodecType.Copy);
            var settingsCollectionI      = SettingsCollection.ForInput(new SeekPositionInput(1));
            var settingsCollectionO      = SettingsCollection.ForOutput(new CodecVideo(VideoCodecType.Libx264));
            var settingsCollectionMergeI = SettingsCollection.ForInput(startAtDefault);
            var settingsCollectionMergeO = SettingsCollection.ForOutput(vcodecDefault);


            Assert.Throws <ArgumentException>(() => settingsCollectionI.MergeRange(settingsCollectionMergeO, FFmpegMergeOptionType.OldWins));
            Assert.Throws <ArgumentException>(() => settingsCollectionO.MergeRange(settingsCollectionMergeI, FFmpegMergeOptionType.OldWins));
            Assert.Throws <ArgumentException>(() => settingsCollectionI.MergeRange(settingsCollectionMergeO, FFmpegMergeOptionType.NewWins));
            Assert.Throws <ArgumentException>(() => settingsCollectionO.MergeRange(settingsCollectionMergeI, FFmpegMergeOptionType.NewWins));

            settingsCollectionI.MergeRange(settingsCollectionMergeI, FFmpegMergeOptionType.OldWins);
            settingsCollectionO.MergeRange(settingsCollectionMergeO, FFmpegMergeOptionType.OldWins);

            var startAtSetting = settingsCollectionI.Items[0] as SeekPositionInput;
            var vcodecSetting  = settingsCollectionO.Items[0] as CodecVideo;

            Assert.False(startAtSetting != null && startAtSetting.Length == startAtDefault.Length);
            Assert.False(vcodecSetting != null && vcodecSetting.Codec == vcodecDefault.Codec);

            settingsCollectionI.MergeRange(settingsCollectionMergeI, FFmpegMergeOptionType.NewWins);
            settingsCollectionO.MergeRange(settingsCollectionMergeO, FFmpegMergeOptionType.NewWins);

            startAtSetting = settingsCollectionI.Items[0] as SeekPositionInput;
            vcodecSetting  = settingsCollectionO.Items[0] as CodecVideo;
            Assert.True(startAtSetting != null && startAtSetting.Length == startAtDefault.Length);
            Assert.True(vcodecSetting != null && vcodecSetting.Codec == vcodecDefault.Codec);
        }
Esempio n. 2
0
        public void SeekPositionInput_Verify()
        {
            var settingWrong1 = new SeekPositionInput(0);
            var settingWrong2 = new SeekPositionInput(-1);
            var setting       = new SeekPositionInput(120);

            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); });
            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); });
            Assert.Equal("-ss 00:02:00.0", SettingSerializer.Serialize(setting));
        }