public async Task WriteLines_WritesCharBuffer() { // Arrange var newLine = Environment.NewLine; var writer = new StringCollectionTextWriter(Encoding.UTF8); // Act writer.WriteLine(); await writer.WriteLineAsync(); // Assert var actual = writer.Entries; Assert.Equal <object>(new[] { newLine, newLine }, actual); }
public async Task Write_WritesStringBuffer() { // Arrange var newLine = Environment.NewLine; var input1 = "Hello"; var input2 = "from"; var input3 = "ASP"; var input4 = ".Net"; var writer = new StringCollectionTextWriter(Encoding.UTF8); // Act writer.Write(input1); writer.WriteLine(input2); await writer.WriteAsync(input3); await writer.WriteLineAsync(input4); // Assert var actual = writer.Entries; Assert.Equal(new[] { input1, input2, newLine, input3, input4, newLine }, actual); }
public async Task Write_WritesCharBuffer() { // Arrange var input1 = new ArraySegment <char>(new char[] { 'a', 'b', 'c', 'd' }, 1, 3); var input2 = new ArraySegment <char>(new char[] { 'e', 'f' }, 0, 2); var input3 = new ArraySegment <char>(new char[] { 'g', 'h', 'i', 'j' }, 3, 1); var writer = new StringCollectionTextWriter(Encoding.UTF8); // Act writer.Write(input1.Array, input1.Offset, input1.Count); await writer.WriteAsync(input2.Array, input2.Offset, input2.Count); await writer.WriteLineAsync(input3.Array, input3.Offset, input3.Count); // Assert var buffer = writer.Entries; Assert.Equal(4, buffer.Count); Assert.Equal("bcd", buffer[0]); Assert.Equal("ef", buffer[1]); Assert.Equal("j", buffer[2]); Assert.Equal(Environment.NewLine, buffer[3]); }