Exemplo n.º 1
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]);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }