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 buffer = new TestHtmlContentBuilder(); var writer = new HtmlContentWrapperTextWriter(buffer, 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 Assert.Collection(buffer.Values, value => Assert.Equal("bcd", value), value => Assert.Equal("ef", value), value => Assert.Equal("j", value), value => Assert.Equal(Environment.NewLine, value)); }
public async Task Write_WritesStringBuffer() { // Arrange var newLine = Environment.NewLine; var input1 = "Hello"; var input2 = "from"; var input3 = "ASP"; var input4 = ".Net"; var buffer = new TestHtmlContentBuilder(); var writer = new HtmlContentWrapperTextWriter(buffer, Encoding.UTF8); // Act writer.Write(input1); writer.WriteLine(input2); await writer.WriteAsync(input3); await writer.WriteLineAsync(input4); // Assert Assert.Equal(new[] { input1, input2, newLine, input3, input4, newLine }, buffer.Values); }
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 buffer = new TestHtmlContentBuilder(); var writer = new HtmlContentWrapperTextWriter(buffer, 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 Assert.Collection(buffer.Values, value => Assert.Equal("bcd", value), value => Assert.Equal("ef", value), value => Assert.Equal("j", value), value => Assert.Equal(Environment.NewLine, value)); }
public async Task Write_WritesStringBuffer() { // Arrange var newLine = Environment.NewLine; var input1 = "Hello"; var input2 = "from"; var input3 = "ASP"; var input4 = ".Net"; var buffer = new TestHtmlContentBuilder(); var writer = new HtmlContentWrapperTextWriter(buffer, Encoding.UTF8); // Act writer.Write(input1); writer.WriteLine(input2); await writer.WriteAsync(input3); await writer.WriteLineAsync(input4); // Assert Assert.Equal(new[] { input1, input2, newLine, input3, input4, newLine }, buffer.Values); }