Пример #1
0
 private static async Task WriteListAsync(TextWriter writer, BufferEntryCollection values)
 {
     foreach (var value in values)
     {
         await writer.WriteAsync(value);
     }
 }
Пример #2
0
 private static void WriteList(TextWriter writer, BufferEntryCollection values)
 {
     foreach (var value in values)
     {
         writer.Write(value);
     }
 }
Пример #3
0
        public void AddWithChar_RepresentsStringsAsChunkedEntries(char[] value, int index, int count, IList <object> expected)
        {
            // Arrange
            var collection = new BufferEntryCollection();

            // Act
            collection.Add(value, index, count);

            // Assert
            Assert.Equal(expected, collection.BufferEntries);
        }
Пример #4
0
        public void AddChar_ThrowsIfCountWouldCauseOutOfBoundReads()
        {
            // Arrange
            var collection = new BufferEntryCollection();

            // Act and Assert
            var ex = Assert.Throws <ArgumentOutOfRangeException>(
                () => collection.Add(new[] { 'a', 'b', 'c' }, 1, 3));

            Assert.Equal("count", ex.ParamName);
        }
Пример #5
0
        public void AddChar_ThrowsIfIndexIsOutOfBounds()
        {
            // Arrange
            var collection = new BufferEntryCollection();

            // Act and Assert
            var ex = Assert.Throws <ArgumentOutOfRangeException>(
                () => collection.Add(new[] { 'a', 'b', 'c' }, -1, 2));

            Assert.Equal("index", ex.ParamName);
        }
Пример #6
0
        public void Add_AddsBufferEntries()
        {
            // Arrange
            var collection = new BufferEntryCollection();
            var inner      = new BufferEntryCollection();

            // Act
            collection.Add("Hello");
            collection.Add(new[] { 'a', 'b', 'c' }, 1, 2);
            collection.Add(inner);

            // Assert
            Assert.Equal("Hello", collection.BufferEntries[0]);
            Assert.Equal("bc", collection.BufferEntries[1]);
            Assert.Same(inner.BufferEntries, collection.BufferEntries[2]);
        }
Пример #7
0
 /// <summary>
 /// Creates a new instance of <see cref="StringCollectionTextWriter"/>.
 /// </summary>
 /// <param name="encoding">The character <see cref="Encoding"/> in which the output is written.</param>
 public StringCollectionTextWriter(Encoding encoding)
 {
     _encoding = encoding;
     Buffer    = new BufferEntryCollection();
 }
Пример #8
0
 public void Enumerator_TraversesThroughBuffer(BufferEntryCollection buffer, string[] expected)
 {
     // Act and Assert
     Assert.Equal(expected, buffer);
 }
Пример #9
0
 /// <summary>
 /// Adds an instance of <see cref="BufferEntryCollection"/> to the buffer.
 /// </summary>
 /// <param name="buffer">The buffer collection to add.</param>
 public void Add([NotNull] BufferEntryCollection buffer)
 {
     _buffer.Add(buffer.BufferEntries);
 }