コード例 #1
0
        public static void SimpleWriter()
        {
            var sw = new ArrayPooledTextWriter();

            sw.Write(4);
            Assert.Equal("4", sw.ToString());
        }
コード例 #2
0
        public static void TestWriteLineObject()
        {
            var sw = new ArrayPooledTextWriter();

            sw.WriteLine(new object());
            Assert.Equal("System.Object" + Environment.NewLine, sw.ToString());
        }
コード例 #3
0
        public static async Task TestWriteLineAsyncCharArray()
        {
            ArrayPooledTextWriter sw = new ArrayPooledTextWriter();
            await sw.WriteLineAsync(new char[] { 'H', 'e', 'l', 'l', 'o' });

            Assert.Equal("Hello" + Environment.NewLine, sw.ToString());
        }
コード例 #4
0
        public static void TestWriteObject()
        {
            var sw = new ArrayPooledTextWriter();

            sw.Write(new object());
            Assert.Equal("System.Object", sw.ToString());
        }
コード例 #5
0
        public static void MiscWrites()
        {
            var sw = new ArrayPooledTextWriter();

            sw.Write('H');
            sw.Write("ello World!");

            Assert.Equal("Hello World!", sw.ToString());
        }
コード例 #6
0
        public static void ToStringReturnsWrittenData()
        {
            var sb = getSb().ToString();
            ArrayPooledTextWriter sw = new ArrayPooledTextWriter();

            sw.Write(sb);

            Assert.Equal(sb, sw.ToString());
        }
コード例 #7
0
        public static async Task MiscWritesAsync()
        {
            var sw = new ArrayPooledTextWriter();
            await sw.WriteAsync('H');

            await sw.WriteAsync(new char[] { 'e', 'l', 'l', 'o', ' ' });

            await sw.WriteAsync("World!");

            Assert.Equal("Hello World!", sw.ToString());
        }
コード例 #8
0
        public static async Task MiscWriteLineAsync()
        {
            var sw = new ArrayPooledTextWriter();
            await sw.WriteLineAsync('H');

            await sw.WriteLineAsync(new char[] { 'e', 'l', 'l', 'o' });

            await sw.WriteLineAsync("World!");

            Assert.Equal(
                string.Format("H{0}ello{0}World!{0}", Environment.NewLine),
                sw.ToString());
        }
コード例 #9
0
        public static void WriteWithOffset()
        {
            ArrayPooledTextWriter sw = new ArrayPooledTextWriter();
            StringReader          sr;

            var chArr = TestDataProvider.CharData;

            sw.Write(chArr, 2, 5);

            sr = new StringReader(sw.ToString());
            for (int i = 2; i < 7; i++)
            {
                int tmp = sr.Read();
                Assert.Equal((int)chArr[i], tmp);
            }
        }
コード例 #10
0
        public static void WriteArray()
        {
            var chArr = TestDataProvider.LargeData;
            var sb    = getSb().ToString();

            ArrayPooledTextWriter sw = new ArrayPooledTextWriter();

            sw.Write(sb);

            var sr = new StringReader(sw.ToString());

            for (int i = 0; i < chArr.Length; i++)
            {
                int tmp = sr.Read();
                Assert.Equal((int)chArr[i], tmp);
            }
        }
コード例 #11
0
        public static void WriteWithLargeIndex()
        {
            for (int i = 0; i < iArrValidValues.Length; i++)
            {
                var sb = new StringBuilder(int.MaxValue / 2000).ToString();
                ArrayPooledTextWriter sw = new ArrayPooledTextWriter();
                sw.Write(sb);

                var chArr = new char[int.MaxValue / 2000];
                for (int j = 0; j < chArr.Length; j++)
                {
                    chArr[j] = (char)(j % 256);
                }
                sw.Write(chArr, iArrValidValues[i] - 1, 1);

                string strTemp = sw.ToString();
                Assert.Equal(1, strTemp.Length);
            }
        }
コード例 #12
0
        public static void NewArrayPooledTextWriterHasEmptyStringBuilder()
        {
            var sw = new ArrayPooledTextWriter();

            Assert.Equal(string.Empty, sw.ToString());
        }