public void WriteObjectId_should_throw_when_subject_is_disposed()
        {
            var stream = Substitute.For<Stream>();
            var subject = new BsonStreamAdapter(stream);
            subject.Dispose();

            Action action = () => subject.WriteObjectId(ObjectId.Empty);

            action.ShouldThrow<ObjectDisposedException>().And.ObjectName.Should().Be("BsonStreamAdapter");
        }
        public void WriteObjectId_should_write_expected_bytes()
        {
            var stream = new MemoryStream();
            var subject = new BsonStreamAdapter(stream);
            var value = ObjectId.GenerateNewId();
            var expectedBytes = value.ToByteArray();

            subject.WriteObjectId(value);

            stream.ToArray().Should().Equal(expectedBytes);
        }
        public void WriteObjectId_should_be_big_endian()
        {
            var stream = new MemoryStream();
            var subject = new BsonStreamAdapter(stream);
            var value = new ObjectId(0x01020304, 0x050607, 0x0809, 0x0a0b0c);
            var expectedBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };

            subject.WriteObjectId(value);

            stream.ToArray().Should().Equal(expectedBytes);
        }