Skip to content

Commit

Permalink
Adds IndentedStringBuilder (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstairs authored May 28, 2019
1 parent e858769 commit 0fb9f80
Show file tree
Hide file tree
Showing 7 changed files with 869 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// -------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// -------------------------------------------------------------------------------------------------

using System;
using System.Text;
using Xunit;

namespace Microsoft.Health.Fhir.SqlServer.UnitTests
{
public class IndentedStringBuilderTests
{
[Fact]
public void GivenAnIndentedStringBuilder_WhenUsingIndentedScopes_KeepsTrackOfIndentation()
{
var sb = new IndentedStringBuilder(new StringBuilder())
.AppendLine("class Foo").AppendLine("{");

using (sb.Indent())
{
sb.AppendLine("Foo()").AppendLine("{");
using (sb.Indent())
{
sb.Append("// ").AppendLine("hello");
}

sb.AppendLine("}");
}

sb.Append("}");

Assert.Equal($"class Foo{Environment.NewLine}{{{Environment.NewLine} Foo(){Environment.NewLine} {{{Environment.NewLine} // hello{Environment.NewLine} }}{Environment.NewLine}}}", sb.ToString());
}
}
}
Loading

0 comments on commit 0fb9f80

Please sign in to comment.