Exemplo n.º 1
0
        public void Map_NullTimestamps_Throws()
        {
            SubtitleTimestamps nullTimestamps = null;
            var mapper = CreateMapper();

            Assert.Throws <ArgumentNullException>(
                () => mapper.Map(nullTimestamps));
        }
Exemplo n.º 2
0
        public void Constructor_NullTimestamps_Throws()
        {
            SubtitleTimestamps nullTimestamps = null;

            Assert.Catch <ArgumentNullException>(
                () => new Subtitle(
                    SubtitleIdTests.CreateId1(),
                    nullTimestamps,
                    CreateStubSubtitleText()));
        }
Exemplo n.º 3
0
        public void Equals_NotEqualTimestamps_ReturnsFalse()
        {
            var t1 = new SubtitleTimestamps(
                TimestampTests.CreateTimestamp(1, 2, 3, 200),
                TimestampTests.CreateTimestamp(5, 2, 3, 200));

            var t2 = new SubtitleTimestamps(
                TimestampTests.CreateTimestamp(2, 2, 3, 2),
                TimestampTests.CreateTimestamp(3, 2, 3, 150));

            Assert.IsFalse(t1.Equals(t2));
        }
Exemplo n.º 4
0
        public void Equals_EqualTimestamps_ReturnsTrue()
        {
            var t1 = new SubtitleTimestamps(
                TimestampTests.CreateTimestamp(1, 2, 3, 200),
                TimestampTests.CreateTimestamp(5, 2, 3, 200));

            var t2 = new SubtitleTimestamps(
                TimestampTests.CreateTimestamp(1, 2, 3, 200),
                TimestampTests.CreateTimestamp(5, 2, 3, 200));

            Assert.IsTrue(t1.Equals(t2));
        }
Exemplo n.º 5
0
        public void Map_Always_ReturnsCharacterLine()
        {
            var mapper = CreateMapper();

            var timestampsToMap = new SubtitleTimestamps(
                TimestampTests.CreateTimestamp(5, 4, 3, 2),
                TimestampTests.CreateTimestamp(5, 4, 4, 0));
            var expectedLine = new CharacterLine("05:04:03,002 --> 05:04:04,000");

            var actualLine = mapper.Map(timestampsToMap);

            Assert.AreEqual(expectedLine, actualLine);
        }
        public void Parse_SuccessfulParsing_ReturnsTimestamps(string timestamps)
        {
            var timestampParser = Substitute.For <ITimestampParser>();

            timestampParser
            .Parse(Arg.Any <SubcharacterLine>())
            .Returns(TimestampTests.CreateTimestamp(5, 5, 5, 5));
            var expectedTimestamps = new SubtitleTimestamps(
                TimestampTests.CreateTimestamp(5, 5, 5, 5),
                TimestampTests.CreateTimestamp(5, 5, 5, 5));

            var timestampsParser = CreateParser(timestampParser);

            var actualTimestamps = timestampsParser.Parse(
                new CharacterLine(timestamps));

            Assert.AreEqual(
                expectedTimestamps,
                actualTimestamps);
        }
Exemplo n.º 7
0
        public void Parse_SuccessfulParsing_ReturnsSubtitle()
        {
            var subtitleToParse = new UnvalidatedSubtitle(
                new List <CharacterLine> {
                new CharacterLine("1"),
                new CharacterLine("00:00:01,100 --> 00:00:03,200"),
                new CharacterLine("Some text"),
                new CharacterLine("More text")
            });

            var stubIdParser = Substitute.For <ISubtitleIdParser>();

            stubIdParser
            .Parse(Arg.Is(new CharacterLine("1")))
            .Returns(new SubtitleId(1));

            var expectedTimestamps = new SubtitleTimestamps(
                TimestampTests.CreateTimestamp(0, 0, 1, 100),
                TimestampTests.CreateTimestamp(0, 0, 3, 200));

            var stubTimestampsParser = Substitute.For <ISubtitleTimestampsParser>();

            stubTimestampsParser
            .Parse(Arg.Is(new CharacterLine("00:00:01,100 --> 00:00:03,200")))
            .Returns(expectedTimestamps);

            var parser = CreateParser(stubIdParser, stubTimestampsParser);

            var expectedSubtitle = new Subtitle(
                new SubtitleId(1),
                expectedTimestamps,
                new SubtitleText(
                    new List <CharacterLine> {
                new CharacterLine("Some text"),
                new CharacterLine("More text")
            }));

            var actualSubtitle = parser.Parse(subtitleToParse);

            Assert.AreEqual(expectedSubtitle, actualSubtitle);
        }