Exemple #1
0
        public void Cloned_Subtitle_IsNotReference()
        {
            var subtitle = SubtitleContainer.GetSubtitleFromFile(SubtitleContainer.ValidSubtitleName);
            var clone    = (ISubtitle)subtitle.Clone();

            Assert.False(subtitle.Items.Equals(clone.Items));
        }
        public void Subtitle_IsOriginal_WhenActionUndone()
        {
            var subtitle         = SubtitleContainer.GetSubtitleFromFile(SubtitleContainer.ValidSubtitleName);
            var offset           = TimeSpan.FromSeconds(1);
            var timeOffsetAction = new SubtitleTimeOffsetAction(offset, subtitle);

            var originalStartTimes = subtitle.Items.Select(s => s.StartTime).ToArray();
            var originalEndTimes   = subtitle.Items.Select(s => s.EndTime).ToArray();

            timeOffsetAction.PerformAction();
            timeOffsetAction.UndoAction();

            var newStartTimes = subtitle.Items.Select(s => s.StartTime).ToArray();
            var newEndTimes   = subtitle.Items.Select(s => s.EndTime).ToArray();

            for (var i = 0; i < originalStartTimes.Length; i++)
            {
                var originalTime = originalStartTimes[i];
                var newTime      = newStartTimes[i];

                Assert.True(newTime == originalTime);
            }

            for (var i = 0; i < originalEndTimes.Length; i++)
            {
                var originalTime = originalEndTimes[i];
                var newTime      = newEndTimes[i];

                Assert.True(newTime == originalTime);
            }
        }
Exemple #3
0
        public void Cloned_Subtitle_MatchesOriginal()
        {
            var subtitle        = SubtitleContainer.GetSubtitleFromFile(SubtitleContainer.ValidSubtitleName);
            var clone           = (ISubtitle)subtitle.Clone();
            var matchesOriginal = !subtitle.Items.Where(
                (t, i) => !string.Equals(
                    t.ToString(),
                    clone.Items[i].ToString(),
                    StringComparison.Ordinal)).Any();

            Assert.True(matchesOriginal);
        }
Exemple #4
0
        public void Subtitle_ToString_MatchesSource()
        {
            var subtitle        = SubtitleContainer.GetSubtitleFromFile(SubtitleContainer.ValidSubtitleName);
            var subtitleCreator = new SubtitleCreator();

            var subtitleString        = subtitle.ToString();
            var reconstructedSubtitle = subtitleCreator.CreateFromString(subtitleString);

            for (var i = 0; i < subtitle.Items.Count; i++)
            {
                Assert.Equal(subtitle.Items[i].ToString(), reconstructedSubtitle.Items[i].ToString());
            }
        }