コード例 #1
0
        public void RecyclingTextWriter_Close_DoesNotCloseInstance()
        {
            var sb     = new System.Text.StringBuilder();
            var writer = new RecyclableStringWriter(sb);

            writer.Close();

            writer.Write("Test");
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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());
        }