public void AppendRangeArraysAfterClear(byte[][] initialContents, byte[][] byteArrays)
            {
                // Arrange
                var builder = new BinaryArray.Builder();

                if (initialContents.Length > 0)
                {
                    builder.AppendRange(initialContents);
                }
                builder.Clear();
                var expectedArrayContents = byteArrays;

                // Act
                var actualReturnValue = builder.AppendRange(byteArrays);

                // Assert
                Assert.Equal(builder, actualReturnValue);
                Assert.Equal(byteArrays.Length, builder.Length);
                var actualArray = builder.Build(_allocator);

                AssertArrayContents(expectedArrayContents, actualArray);
            }
            public void BuildMultipleTimes(byte[][] byteArrays)
            {
                // Arrange
                var builder = new BinaryArray.Builder();

                builder.AppendRange(byteArrays);
                builder.Build(_allocator);

                // Act
                var array = builder.Build(_allocator);

                // Assert
                AssertArrayContents(byteArrays, array);
            }
            public void AppendRangeArrays(byte[][] initialContents, byte[][] byteArrays)
            {
                // Arrange
                var builder = new BinaryArray.Builder();

                if (initialContents.Length > 0)
                {
                    builder.AppendRange(initialContents);
                }
                int initialLength         = builder.Length;
                int expectedNewLength     = initialLength + byteArrays.Length;
                var expectedArrayContents = initialContents.Concat(byteArrays);

                // Act
                var actualReturnValue = builder.AppendRange(byteArrays);

                // Assert
                Assert.Equal(builder, actualReturnValue);
                Assert.Equal(expectedNewLength, builder.Length);
                var actualArray = builder.Build(_allocator);

                AssertArrayContents(expectedArrayContents, actualArray);
            }
            public void ClearNonEmpty(byte[][] byteArrays)
            {
                // Arrange
                var builder = new BinaryArray.Builder();

                builder.AppendRange(byteArrays);

                // Act
                var actualReturnValue = builder.Clear();

                // Assert
                Assert.NotNull(actualReturnValue);
                Assert.Equal(builder, actualReturnValue);
                Assert.Equal(0, builder.Length);
                var array = builder.Build(_allocator);

                Assert.Equal(0, array.Length);
            }
            public void AppendSingleByte(byte[][] initialContents, byte singleByte)
            {
                // Arrange
                var builder = new BinaryArray.Builder();

                if (initialContents.Length > 0)
                {
                    builder.AppendRange(initialContents);
                }
                int initialLength         = builder.Length;
                int expectedLength        = initialLength + 1;
                var expectedArrayContents = initialContents.Append(new[] { singleByte });

                // Act
                var actualReturnValue = builder.Append(singleByte);

                // Assert
                Assert.Equal(builder, actualReturnValue);
                Assert.Equal(expectedLength, builder.Length);
                var actualArray = builder.Build(_allocator);

                AssertArrayContents(expectedArrayContents, actualArray);
            }
            public void AppendEnumerableAfterClear(byte[][] initialContents, byte[] bytes)
            {
                // Arrange
                var builder = new BinaryArray.Builder();

                if (initialContents.Length > 0)
                {
                    builder.AppendRange(initialContents);
                }
                builder.Clear();
                var enumerable            = (IEnumerable <byte>)bytes;
                var expectedArrayContents = new[] { bytes };

                // Act
                var actualReturnValue = builder.Append(enumerable);

                // Assert
                Assert.Equal(builder, actualReturnValue);
                Assert.Equal(1, builder.Length);
                var actualArray = builder.Build(_allocator);

                AssertArrayContents(expectedArrayContents, actualArray);
            }
            public void AppendReadOnlySpan(byte[][] initialContents, byte[] bytes)
            {
                // Arrange
                var builder = new BinaryArray.Builder();

                if (initialContents.Length > 0)
                {
                    builder.AppendRange(initialContents);
                }
                int initialLength         = builder.Length;
                var span                  = (ReadOnlySpan <byte>)bytes;
                int expectedLength        = initialLength + 1;
                var expectedArrayContents = initialContents.Append(bytes);

                // Act
                var actualReturnValue = builder.Append(span);

                // Assert
                Assert.Equal(builder, actualReturnValue);
                Assert.Equal(expectedLength, builder.Length);
                var actualArray = builder.Build(_allocator);

                AssertArrayContents(expectedArrayContents, actualArray);
            }