public void CalculatePaddingForEmptySpanReturnsZero()
        {
            // Arrange
            var host = CreateHost(designTime: true);

            var span = new Span(new SpanBuilder());

            var paddingBuilder = new CSharpPaddingBuilder(host);

            // Act
            var padding = paddingBuilder.CalculatePadding(span, 0);

            // Assert
            Assert.Equal(0, padding);
        }
        public void CalculatePaddingForIfSpanWith5Spaces(bool designTime, bool isIndentingWithTabs, int tabSize)
        {
            // Arrange
            var host = CreateHost(designTime, isIndentingWithTabs, tabSize);

            var span = GenerateSpan(@"    @if (true)", SpanKind.Code, 2, "if (true)");

            var paddingBuilder = new CSharpPaddingBuilder(host);

            // Act
            var padding = paddingBuilder.CalculatePadding(span, 1);

            // Assert
            Assert.Equal(4, padding);
        }
        public void VerifyPaddingForIfSpanWith4Spaces(bool designTime, bool isIndentingWithTabs, int tabSize, int numTabs, int numSpaces)
        {
            // Arrange
            var host = CreateHost(designTime, isIndentingWithTabs, tabSize);

            // no new lines involved
            var spanFlat = GenerateSpan("    @if (true)", SpanKind.Code, 2, "if (true)");
            var spanNewlines = GenerateSpan("\t<div>" + Environment.NewLine + "    @if (true)", SpanKind.Code, 5, "if (true)");

            var paddingBuilder = new CSharpPaddingBuilder(host);

            // Act
            var paddingFlat = paddingBuilder.BuildStatementPadding(spanFlat);
            var paddingNewlines = paddingBuilder.BuildStatementPadding(spanNewlines);

            // Assert
            var code = " if (true)";
            VerifyPadded(numTabs, numSpaces, code, paddingFlat);
            VerifyPadded(numTabs, numSpaces, code, paddingNewlines);
        }
        public void CalculatePaddingForOpenedIf(bool designTime, bool isIndentingWithTabs, int tabSize, int numTabs, int numSpaces)
        {
            // Arrange
            var host = CreateHost(designTime, isIndentingWithTabs, tabSize);

            var text = string.Format("{0}<html>{0}<body>{0}\t\t@if (true) {{ {0}</body>{0}</html>", Environment.NewLine);

            var code = "if (true) { " + Environment.NewLine;
            var span = GenerateSpan(text, SpanKind.Code, 7, code);

            var paddingBuilder = new CSharpPaddingBuilder(host);

            // Act
            var padding = paddingBuilder.BuildStatementPadding(span);

            // Assert
            VerifyPadded(numTabs, numSpaces, code, padding);
        }