Ejemplo n.º 1
0
        public void BackpatchSize_should_throw_when_size_is_larger_than_2GB()
        {
            using (var stream = new NullBsonStream())
                using (var binaryWriter = new BsonBinaryWriter(stream))
                {
                    var bytes      = new byte[int.MaxValue / 2]; // 1GB
                    var binaryData = new BsonBinaryData(bytes);

                    binaryWriter.WriteStartDocument();
                    binaryWriter.WriteName("array");
                    binaryWriter.WriteStartArray();
                    binaryWriter.WriteBinaryData(binaryData);
                    binaryWriter.WriteBinaryData(binaryData);

                    Action action = () => binaryWriter.WriteEndArray(); // indirectly calls private BackpatchSize method

                    action.ShouldThrow <FormatException>();
                }
        }