public void WriteLine_WritesDataTypes_ToBuffer()
        {
            // Arrange
            var newLine  = Environment.NewLine;
            var expected = new List <object> {
                "False", newLine, "1.1", newLine, "3", newLine
            };
            var writer = new StringCollectionTextWriter(Encoding.UTF8);

            // Act
            writer.WriteLine(false);
            writer.WriteLine(1.1f);
            writer.WriteLine(3L);

            // Assert
            Assert.Equal(expected, writer.Entries);
        }
        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 void Copy_WritesContent_IfTargetTextWriterIsNotAStringCollectionTextWriter()
        {
            // Arrange
            var source   = new StringCollectionTextWriter(Encoding.UTF8);
            var target   = new StringWriter();
            var expected = @"Hello world" + Environment.NewLine + "abc";

            // Act
            source.WriteLine("Hello world");
            source.Write(new[] { 'x', 'a', 'b', 'c' }, 1, 3);
            source.CopyTo(target, new CommonTestEncoder());

            // Assert
            Assert.Equal(expected, target.ToString());
        }
        public void WriteLine_Object_HtmlContent_AddsToEntries()
        {
            // Arrange
            var writer  = new StringCollectionTextWriter(Encoding.UTF8);
            var content = new HtmlString("Hello, world!");

            // Act
            writer.WriteLine(content);

            // Assert
            Assert.Collection(
                writer.Entries,
                item => Assert.Same(content, item),
                item => Assert.Equal(Environment.NewLine, item));
        }
        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);
        }