コード例 #1
0
        public void ParseLine_ReturnsBlockStateNoneIfCurrentLineDoesNotBeginWithExclamationMarkAndIsNotBlank()
        {
            // Arrange
            BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor();

            dummyBlockProcessor.Line = new StringSlice("dummyString");
            ExposedFlexiAlertBlockParser testSubject = CreateExposedFlexiAlertBlockParser();

            // Act
            BlockState result = testSubject.ParseLine(dummyBlockProcessor, null);

            // Assert
            Assert.Equal(BlockState.None, result);
        }
コード例 #2
0
        public void ParseLine_ReturnsBlockStateNoneIfCurrentLineHasCodeIndent()
        {
            // Arrange
            BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor();

            dummyBlockProcessor.Column = 4; // IsCodeIndent is an expression bodied member that derives its value from Column
            ExposedFlexiAlertBlockParser testSubject = CreateExposedFlexiAlertBlockParser();

            // Act
            BlockState result = testSubject.ParseLine(dummyBlockProcessor, null);

            // Assert
            Assert.Equal(BlockState.None, result);
        }
コード例 #3
0
        public void ParseLine_ReturnsBlockStateBreakDiscardIfCurrentLineIsBlank()
        {
            // Arrange
            BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor();

            dummyBlockProcessor.Line = new StringSlice(string.Empty);
            ExposedFlexiAlertBlockParser testSubject = CreateExposedFlexiAlertBlockParser();

            // Act
            BlockState result = testSubject.ParseLine(dummyBlockProcessor, null);

            // Assert
            Assert.Equal(BlockState.BreakDiscard, result);
        }
コード例 #4
0
        public void ParseLine_ReturnsBlockStateNoneIfSecondCharacterIsOpeningSquareBracket()
        {
            // Arrange
            var            dummyLine           = new StringSlice("![");
            BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor();

            dummyBlockProcessor.Line = dummyLine;
            ExposedFlexiAlertBlockParser testSubject = CreateExposedFlexiAlertBlockParser();

            // Act
            BlockState result = testSubject.ParseLine(dummyBlockProcessor, null);

            // Assert
            Assert.Equal(BlockState.None, result);
        }
コード例 #5
0
        public void ParseLine_UpdatesFlexiAlertBlockAndReturnsBlockStateContinueIfFlexiAlertBlockCanBeContinued()
        {
            // Arrange
            var            dummyLine           = new StringSlice("! dummyLine");
            BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor();

            dummyBlockProcessor.Line = dummyLine;
            FlexiAlertBlock dummyFlexiAlertBlock     = CreateFlexiAlertBlock();
            ExposedFlexiAlertBlockParser testSubject = CreateExposedFlexiAlertBlockParser();

            // Act
            BlockState result = testSubject.ParseLine(dummyBlockProcessor, dummyFlexiAlertBlock);

            // Assert
            Assert.Equal(BlockState.Continue, result);
            Assert.Equal(dummyLine.End, dummyFlexiAlertBlock.Span.End);
            Assert.Equal(2, dummyBlockProcessor.Start); // Skips ! and first space
        }
コード例 #6
0
        public void ParseLine_IfSuccessfullyParsedStartLineOfABlockCreatesNewFlexiAlertBlockAdvancesCurrentCharAndReturnsBlockStateContinue()
        {
            // Arrange
            var            dummyLine           = new StringSlice("! dummyLine");
            BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor();

            dummyBlockProcessor.Line = dummyLine;
            FlexiAlertBlock dummyFlexiAlertBlock = CreateFlexiAlertBlock();
            Mock <IFlexiAlertBlockFactory> mockFlexiAlertBlockFactory = _mockRepository.Create <IFlexiAlertBlockFactory>();
            ExposedFlexiAlertBlockParser   testSubject = CreateExposedFlexiAlertBlockParser(mockFlexiAlertBlockFactory.Object);

            mockFlexiAlertBlockFactory.Setup(f => f.Create(dummyBlockProcessor, testSubject)).Returns(dummyFlexiAlertBlock);

            // Act
            BlockState result = testSubject.ParseLine(dummyBlockProcessor, null);

            // Assert
            _mockRepository.VerifyAll();
            Assert.Equal(BlockState.Continue, result);
            var resultBlock = dummyBlockProcessor.NewBlocks.Peek() as FlexiAlertBlock;

            Assert.Same(dummyFlexiAlertBlock, resultBlock);
            Assert.Equal(2, dummyBlockProcessor.Start); // Skips ! and first space
        }