Exemple #1
0
        public void WritePanel_WritesPanel(FlexiTabBlock dummyFlexiTabBlock, string dummyBlockName, int dummyIndex, string expectedResult)
        {
            // Arrange
            var dummyStringWriter = new StringWriter();
            var dummyHtmlRenderer = new HtmlRenderer(dummyStringWriter);
            FlexiTabsBlockRenderer testSubject = CreateFlexiTabsBlockRenderer();

            // Act
            testSubject.WritePanel(dummyHtmlRenderer, dummyFlexiTabBlock, dummyBlockName, dummyIndex);
            string result = dummyStringWriter.ToString();

            // Assert
            Assert.Equal(expectedResult, result, ignoreLineEndingDifferences: true);
        }
Exemple #2
0
        public void WriteTab_WritesUnselectedTabIfIndexIsLargerThan0()
        {
            // Arrange
            FlexiTabBlock          dummyFlexiTabBlock = CreateFlexiTabBlock();
            var                    dummyStringWriter  = new StringWriter();
            var                    dummyHtmlRenderer  = new HtmlRenderer(dummyStringWriter);
            FlexiTabsBlockRenderer testSubject        = CreateFlexiTabsBlockRenderer();

            // Act
            testSubject.WriteTab(dummyHtmlRenderer, dummyFlexiTabBlock, null, 1);
            string result = dummyStringWriter.ToString();

            // Assert
            Assert.Equal(@"<button class=""__tab"" role=""tab"" aria-selected=""false"" tabindex=""-1""></button>
",
                         result,
                         ignoreLineEndingDifferences: true);
        }
        public void Create_CreatesFlexiTabBlock()
        {
            // Arrange
            const int                     dummyColumn               = 2;
            var                           dummyLine                 = new StringSlice("dummyText", 3, 8);
            IFlexiTabBlockOptions         dummyDefaultTabOptions    = _mockRepository.Create <IFlexiTabBlockOptions>().Object;
            Mock <IFlexiTabsBlockOptions> mockFlexiTabsBlockOptions = _mockRepository.Create <IFlexiTabsBlockOptions>();

            mockFlexiTabsBlockOptions.Setup(f => f.DefaultTabOptions).Returns(dummyDefaultTabOptions);
            Mock <BlockParser>  dummyBlockParser         = _mockRepository.Create <BlockParser>();
            ProxyFlexiTabsBlock dummyProxyFlexiTabsBlock = CreateProxyFlexiTabsBlock(mockFlexiTabsBlockOptions.Object, blockParser: dummyBlockParser.Object);
            BlockProcessor      dummyBlockProcessor      = MarkdigTypesFactory.CreateBlockProcessor();

            // Following 3 lines set dummyBlockProcessor.CurrentContainer
            dummyBlockParser.Setup(b => b.TryContinue(dummyBlockProcessor, dummyProxyFlexiTabsBlock)).Returns(BlockState.ContinueDiscard);
            dummyBlockProcessor.Open(dummyProxyFlexiTabsBlock);
            dummyBlockProcessor.ProcessLine(new StringSlice(string.Empty));
            dummyBlockProcessor.Column = dummyColumn;
            dummyBlockProcessor.Line   = dummyLine;
            var dummyAttributes = new ReadOnlyDictionary <string, string>(new Dictionary <string, string>());
            Mock <IFlexiTabBlockOptions> mockFlexiTabBlockOptions = _mockRepository.Create <IFlexiTabBlockOptions>();

            mockFlexiTabBlockOptions.Setup(f => f.Attributes).Returns(dummyAttributes);
            Mock <IBlockOptionsFactory <IFlexiTabBlockOptions> > mockFlexiTabBlockOptionsFactory = _mockRepository.
                                                                                                   Create <IBlockOptionsFactory <IFlexiTabBlockOptions> >();

            mockFlexiTabBlockOptionsFactory.Setup(f => f.Create(dummyDefaultTabOptions, dummyBlockProcessor)).Returns(mockFlexiTabBlockOptions.Object);
            FlexiTabBlockFactory testSubject = CreateFlexiTabBlockFactory(mockFlexiTabBlockOptionsFactory.Object);

            // Act
            FlexiTabBlock result = testSubject.Create(dummyBlockProcessor, dummyBlockParser.Object);

            // Assert
            _mockRepository.VerifyAll();
            Assert.Same(dummyAttributes, result.Attributes);
            Assert.Same(dummyBlockParser.Object, result.Parser);
            Assert.Equal(dummyColumn, result.Column);
            Assert.Equal(dummyLine.Start, result.Span.Start);
            Assert.Equal(0, result.Span.End);
        }