Exemple #1
0
        public void ToStringAndClear_Clears()
        {
            InterpolatedStringBuilder builder = InterpolatedStringBuilder.Create(0, 0);

            builder.AppendLiteral("hi");
            Assert.Equal("hi", builder.ToStringAndClear());
            Assert.Equal(string.Empty, builder.ToStringAndClear());
        }
Exemple #2
0
        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());
        }
Exemple #3
0
        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());
        }