public async Task WriteLineAsyncCharArrayIndexCount()
        {
            using (CharArrayTextWriter tw = NewTextWriter)
            {
                await tw.WriteLineAsync(TestDataProvider.CharData, 3, 5);

                Assert.Equal(new string(TestDataProvider.CharData, 3, 5) + tw.NewLine, tw.Text);
            }
        }
 public void WriteCharSpanTest()
 {
     using (CharArrayTextWriter tw = NewTextWriter)
     {
         var rs = new ReadOnlySpan <char>(TestDataProvider.CharData, 4, 6);
         tw.Write(rs);
         Assert.Equal(new string(rs), tw.Text);
     }
 }
        public async Task WriteLineAsyncCharTest()
        {
            using (CharArrayTextWriter tw = NewTextWriter)
            {
                await tw.WriteLineAsync('a');

                Assert.Equal("a" + tw.NewLine, tw.Text);
            }
        }
示例#4
0
        public async void WriteAsyncCharArrayIndexCountTest()
        {
            using (CharArrayTextWriter tw = NewTextWriter)
            {
                await tw.WriteAsync(TestDataProvider.CharData, 3, 5);

                Assert.Equal(new string(TestDataProvider.CharData, 3, 5), tw.Text);
            }
        }
示例#5
0
        public async void WriteLineAsyncTest()
        {
            using (CharArrayTextWriter tw = NewTextWriter)
            {
                await tw.WriteLineAsync();

                Assert.Equal(tw.NewLine, tw.Text);
            }
        }
示例#6
0
        public async void WriteAsyncCharTest()
        {
            using (CharArrayTextWriter tw = NewTextWriter)
            {
                await tw.WriteAsync('a');

                Assert.Equal("a", tw.Text);
            }
        }
 public void WriteLineStringBuilderTest(bool isSynchronized, StringBuilder testData)
 {
     using (CharArrayTextWriter ctw = NewTextWriter)
     {
         TextWriter tw = isSynchronized ? TextWriter.Synchronized(ctw) : ctw;
         tw.WriteLine(testData);
         tw.Flush();
         Assert.Equal(testData.ToString() + tw.NewLine, ctw.Text);
     }
 }
示例#8
0
        public async Task WriteLineCharMemoryTest()
        {
            using (CharArrayTextWriter tw = NewTextWriter)
            {
                var rs = new Memory <char>(TestDataProvider.CharData, 4, 6);
                await tw.WriteLineAsync(rs);

                Assert.Equal(new string(rs.Span) + tw.NewLine, tw.Text);
            }
        }
示例#9
0
        public async Task WriteLineAsyncStringTest()
        {
            using (CharArrayTextWriter tw = NewTextWriter)
            {
                var toWrite = new string(TestDataProvider.CharData);
                await tw.WriteLineAsync(toWrite);

                Assert.Equal(toWrite + tw.NewLine, tw.Text);
            }
        }
示例#10
0
 public void WriteLineCharTest()
 {
     using (CharArrayTextWriter tw = NewTextWriter)
     {
         for (int count = 0; count < TestDataProvider.CharData.Length; ++count)
         {
             tw.WriteLine(TestDataProvider.CharData[count]);
         }
         Assert.Equal(string.Join(tw.NewLine, TestDataProvider.CharData.Select(ch => ch.ToString()).ToArray()) + tw.NewLine, tw.Text);
     }
 }
示例#11
0
 public void WriteCharTest()
 {
     using (CharArrayTextWriter tw = NewTextWriter)
     {
         for (int count = 0; count < TestDataProvider.CharData.Length; ++count)
         {
             tw.Write(TestDataProvider.CharData[count]);
         }
         Assert.Equal(new string(TestDataProvider.CharData), tw.Text);
     }
 }
示例#12
0
        public async Task WriteLineAsyncStringBuilderTest(bool isSynchronized, StringBuilder testData)
        {
            using (CharArrayTextWriter ctw = NewTextWriter)
            {
                TextWriter tw = isSynchronized ? TextWriter.Synchronized(ctw) : ctw;
                await tw.WriteLineAsync(testData);

                tw.Flush();
                Assert.Equal(testData + tw.NewLine, ctw.Text);
            }
        }
示例#13
0
        public void WriteLongTest()
        {
            using (CharArrayTextWriter tw = NewTextWriter)
            {
                tw.Write(long.MinValue);
                Assert.Equal(long.MinValue.ToString(), tw.Text);

                tw.Clear();
                tw.Write(long.MaxValue);
                Assert.Equal(long.MaxValue.ToString(), tw.Text);
            }
        }
示例#14
0
        public void WriteBoolTest()
        {
            using (CharArrayTextWriter tw = NewTextWriter)
            {
                tw.Write(true);
                Assert.Equal("True", tw.Text);

                tw.Clear();
                tw.Write(false);
                Assert.Equal("False", tw.Text);
            }
        }
示例#15
0
        public void WriteLineDecimalTest()
        {
            using (CharArrayTextWriter tw = NewTextWriter)
            {
                tw.WriteLine(decimal.MinValue);
                Assert.Equal(decimal.MinValue.ToString() + tw.NewLine, tw.Text);

                tw.Clear();
                tw.WriteLine(decimal.MaxValue);
                Assert.Equal(decimal.MaxValue.ToString() + tw.NewLine, tw.Text);
            }
        }
示例#16
0
        public void WriteLineFloatTest()
        {
            using (CharArrayTextWriter tw = NewTextWriter)
            {
                tw.WriteLine(float.MinValue);
                Assert.Equal(float.MinValue.ToString() + tw.NewLine, tw.Text);

                tw.Clear();
                tw.WriteLine(float.MaxValue);
                Assert.Equal(float.MaxValue.ToString() + tw.NewLine, tw.Text);

                tw.Clear();
                tw.WriteLine(float.NaN);
                Assert.Equal(float.NaN.ToString() + tw.NewLine, tw.Text);
            }
        }
示例#17
0
        public async Task WriteLineAsyncStringBuilderTest(bool isSynchronized, StringBuilder testData)
        {
            if (!isSynchronized && !PlatformDetection.IsThreadingSupported)
            {
                throw new SkipTestException(nameof(PlatformDetection.IsThreadingSupported));
            }

            using (CharArrayTextWriter ctw = NewTextWriter)
            {
                TextWriter tw = isSynchronized ? TextWriter.Synchronized(ctw) : ctw;
                await tw.WriteLineAsync(testData);

                tw.Flush();
                Assert.Equal(testData + tw.NewLine, ctw.Text);
            }
        }
示例#18
0
        public void WriteDoubleTest()
        {
            using (CharArrayTextWriter tw = NewTextWriter)
            {
                tw.Write(double.MinValue);
                Assert.Equal(double.MinValue.ToString(), tw.Text);
                tw.Clear();

                tw.Write(double.MaxValue);
                Assert.Equal(double.MaxValue.ToString(), tw.Text);
                tw.Clear();

                tw.Write(double.NaN);
                Assert.Equal(double.NaN.ToString(), tw.Text);
                tw.Clear();
            }
        }