public void ToStringAndClear_Clears() { InterpolatedStringBuilder builder = InterpolatedStringBuilder.Create(0, 0); builder.AppendLiteral("hi"); Assert.Equal("hi", builder.ToStringAndClear()); Assert.Equal(string.Empty, builder.ToStringAndClear()); }
public void ToString_DoesntClear() { InterpolatedStringBuilder builder = InterpolatedStringBuilder.Create(0, 0); builder.AppendLiteral("hi"); for (int i = 0; i < 3; i++) { Assert.Equal("hi", builder.ToString()); } Assert.Equal("hi", builder.ToStringAndClear()); }
public void AppendLiteral() { var expected = new StringBuilder(); InterpolatedStringBuilder actual = InterpolatedStringBuilder.Create(0, 0); foreach (string s in new[] { "", "a", "bc", "def", "this is a long string", "!" }) { expected.Append(s); actual.AppendLiteral(s); } Assert.Equal(expected.ToString(), actual.ToStringAndClear()); }