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_Dispose_DoesNotSetCapacityWhenUnderMaxSize()
        {
            var sb     = new System.Text.StringBuilder();
            var writer = new RecyclableStringWriter(sb);

            writer.Write(new string('A', 600));
            writer.Dispose();

            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());
        }