public void RecyclingTextWriter_Close_DoesNotCloseInstance() { var sb = new System.Text.StringBuilder(); var writer = new RecyclableStringWriter(sb); writer.Close(); writer.Write("Test"); }
public void RecyclingTextWriter_Close_DoesNotSetCapacityWhenUnderMaxSize() { var sb = new System.Text.StringBuilder(); var writer = new RecyclableStringWriter(sb); writer.Write(new string('A', 600)); writer.Close(); Assert.AreEqual(600, sb.Capacity); Assert.AreEqual(0, sb.Length); Assert.AreEqual(String.Empty, sb.ToString()); }
public void RecyclingTextWriter_Close_SetsCapacityWhenOverSize() { var sb = new System.Text.StringBuilder(); var writer = new RecyclableStringWriter(sb, System.Globalization.CultureInfo.CurrentCulture, 1024, 512); writer.Write(new string('A', 2048)); writer.Close(); Assert.AreEqual(512, sb.Capacity); Assert.AreEqual(0, sb.Length); Assert.AreEqual(String.Empty, sb.ToString()); }
public void RecyclingTextWriter_Close_ResetsStringBuilder() { var sb = new System.Text.StringBuilder(); var writer = new RecyclableStringWriter(sb); writer.Write("Test"); Assert.AreEqual("Test", sb.ToString()); writer.Close(); Assert.AreEqual(0, sb.Length); Assert.AreEqual(String.Empty, sb.ToString()); }