public void RecyclingTextWriter_GetText_ReturnsWrittenText() { var sb = new System.Text.StringBuilder(); var writer = new RecyclableStringWriter(sb); writer.Write("A test string. "); writer.Write("Some more test text."); var actual = writer.GetText(); Assert.AreEqual("A test string. Some more test text.", actual); }
public void RecyclingTextWriter_ForceDispose_ReallyDisposes() { var writer = new RecyclableStringWriter(); writer.ForceDispose(); writer.Write("Test"); }
public void RecyclingTextWriter_Dispose_DoesNotDisposeInstance() { var sb = new System.Text.StringBuilder(); var writer = new RecyclableStringWriter(sb); writer.Dispose(); writer.Write("Test"); }
public void RecyclingTextWriter_Dispose_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.Dispose(); Assert.AreEqual(512, sb.Capacity); Assert.AreEqual(0, sb.Length); Assert.AreEqual(String.Empty, sb.ToString()); }
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_Dispose_ResetsStringBuilder() { var sb = new System.Text.StringBuilder(); var writer = new RecyclableStringWriter(sb); writer.Write("Test"); Assert.AreEqual("Test", sb.ToString()); writer.Dispose(); Assert.AreEqual(0, sb.Length); Assert.AreEqual(String.Empty, sb.ToString()); }