public void TestDoubleRoundTripOn64BitProcess() { RequireProcess.Check().Bits(64); var value = 0.6822871999174; // see: https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx#RFormatString var json = value.ToJson(); var rehydrated = BsonSerializer.Deserialize <double>(json); rehydrated.Should().Be(value); }
public void ExpandCapacity_should_throw_when_expanded_capacity_exceeds_2GB() { RequireProcess.Check().Bits(64); using (var subject = new MultiChunkBuffer(BsonChunkPool.Default)) { subject.EnsureCapacity(int.MaxValue - 128 * 1024 * 1024); Action action = () => subject.EnsureCapacity(int.MaxValue); // indirectly calls private ExpandCapacity method action.ShouldThrow <InvalidOperationException>(); } }
public void TestLargeDocumentDeserialization() { RequireProcess.Check().Bits(64); var bsonDocument = new BsonDocument { { "stringfield", "A" } }; var noOfDoubleFields = 200000; for (var i = 0; i < noOfDoubleFields; i++) { bsonDocument.Add("doublefield_" + i, i * 1.0); } var bson = bsonDocument.ToBson(); using (var lazyBsonDocument = BsonSerializer.Deserialize <LazyBsonDocument>(bson)) { Assert.Equal(noOfDoubleFields + 1, lazyBsonDocument.ElementCount); } }
public void BackpatchSize_should_throw_when_size_is_larger_than_2GB() { RequireProcess.Is64Bit(); 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>(); } }
public void BsonBinaryWriter_should_support_writing_more_than_2GB() { RequireProcess.Is64Bit(); using (var stream = new NullBsonStream()) using (var binaryWriter = new BsonBinaryWriter(stream)) { var bigBinaryData = new BsonBinaryData(new byte[int.MaxValue / 2 - 1000]); for (var i = 0; i < 3; i++) { binaryWriter.WriteStartDocument(); binaryWriter.WriteName("x"); binaryWriter.WriteBinaryData(bigBinaryData); binaryWriter.WriteEndDocument(); } var smallBinaryData = new BsonBinaryData(new byte[2000]); binaryWriter.WriteStartDocument(); binaryWriter.WriteName("x"); binaryWriter.WriteBinaryData(smallBinaryData); binaryWriter.WriteEndDocument(); } }