public void RestoresPreviousIndentLevelOnDisposalWithSpecifiedAmount() { // Given StringBuilder builder = new StringBuilder(); OutputFile output = new OutputFileWriter(new StringWriter(builder)); string expected = @"A B C D E "; // When output.WriteLine("A"); using (output.WithIndent()) { output.WriteLine("B"); using (output.WithIndent(0)) { output.WriteLine("C"); } output.WriteLine("D"); } output.WriteLine("E"); // Then Assert.AreEqual(expected, builder.ToString()); }
public void IndentsUntilDisposal() { // Given StringBuilder builder = new StringBuilder(); OutputFile output = new OutputFileWriter(new StringWriter(builder)); string expected = @"A B C "; // When output.WriteLine("A"); using (output.WithIndent()) { output.WriteLine("B"); } output.WriteLine("C"); // Then Assert.AreEqual(expected, builder.ToString()); }
public void DoesNotResetIndentWriteFlag() { // Given StringBuilder builder = new StringBuilder(); OutputFile output = new OutputFileWriter(new StringWriter(builder)); string expected = @"A ....B C "; // When output.IndentString = ".."; output.WriteLine("A"); using (output.WithIndent()) { output.WriteIndent(); output.WriteLine("B"); } output.WriteLine("C"); // Then Assert.AreEqual(expected, builder.ToString()); }