Beispiel #1
0
        public void StartAt_Verify()
        {
            var settingWrong1 = new StartAt(0);
            var settingWrong2 = new StartAt(-1);
            var setting = new StartAt(120);

            Assert.Throws<InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); });
            Assert.Throws<InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); });
            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting));
            Assert.Equal(SettingSerializer.Serialize(setting), "-ss 00:02:00.0");
        }
        public void SettingsCollection_Merge()
        {
            var settingsCollectionI = SettingsCollection.ForInput(new StartAt(1));
            var settingsCollectionO = SettingsCollection.ForOutput(new CodecVideo(VideoCodecType.Libx264));
            var startAtDefault = new StartAt(2);
            var vcodecDefault = new CodecVideo(VideoCodecType.Copy);

            Assert.DoesNotThrow(() => settingsCollectionI.Merge(startAtDefault, FFmpegMergeOptionType.OldWins));

            var startAtSetting = settingsCollectionI.Items[0] as StartAt;
            Assert.False(startAtSetting != null && startAtSetting.Length == startAtDefault.Length);

            Assert.DoesNotThrow(() => settingsCollectionI.Merge(startAtDefault, FFmpegMergeOptionType.NewWins));

            startAtSetting = settingsCollectionI.Items[0] as StartAt;
            Assert.True(startAtSetting != null && startAtSetting.Length == startAtDefault.Length);

            Assert.Throws<ArgumentException>(() => settingsCollectionI.Merge(vcodecDefault, FFmpegMergeOptionType.OldWins));
            Assert.Throws<ArgumentException>(() => settingsCollectionI.Merge(vcodecDefault, FFmpegMergeOptionType.NewWins));

            Assert.DoesNotThrow(() => settingsCollectionO.Merge(vcodecDefault, FFmpegMergeOptionType.OldWins));

            var vcodecSetting = settingsCollectionO.Items[0] as CodecVideo;
            Assert.False(vcodecSetting != null && vcodecSetting.Codec == vcodecDefault.Codec);

            Assert.DoesNotThrow(() => settingsCollectionO.Merge(vcodecDefault, FFmpegMergeOptionType.NewWins));

            vcodecSetting = settingsCollectionO.Items[0] as CodecVideo;
            Assert.True(vcodecSetting != null && vcodecSetting.Codec == vcodecDefault.Codec);

            Assert.Throws<ArgumentException>(() => settingsCollectionO.Merge(startAtDefault, FFmpegMergeOptionType.OldWins));
            Assert.Throws<ArgumentException>(() => settingsCollectionO.Merge(startAtDefault, FFmpegMergeOptionType.NewWins));
        }
        public void StartAt_Verify()
        {
            var settingWrong1 = new StartAt(0);
            var settingWrong2 = new StartAt(-1);
            var setting = new StartAt(120);

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