public void Buffer_Write_Types() { var source = new BufferSlice(new byte[1000], 0, 1000); var g = Guid.NewGuid(); var d = DateTime.Now; var o = ObjectId.NewObjectId(); using (var w = new BufferWriter(source)) { w.Write(true); w.Write(false); w.Write(DateTime.MinValue); w.Write(DateTime.MaxValue); w.Write(d); w.Write(Guid.Empty); w.Write(g); w.Write(ObjectId.Empty); w.Write(o); w.Write(PageAddress.Empty); w.Write(new PageAddress(199, 0)); } var p = 0; source.ReadBool(p).Should().BeTrue(); p += 1; source.ReadBool(p).Should().BeFalse(); p += 1; source.ReadDateTime(p).Should().Be(DateTime.MinValue); p += 8; source.ReadDateTime(p).Should().Be(DateTime.MaxValue); p += 8; source.ReadDateTime(p).Should().Be(d); p += 8; source.ReadGuid(p).Should().Be(Guid.Empty); p += 16; source.ReadGuid(p).Should().Be(g); p += 16; source.ReadObjectId(p).Should().Be(ObjectId.Empty); p += 12; source.ReadObjectId(p).Should().Be(o); p += 12; source.ReadPageAddress(p).Should().Be(PageAddress.Empty); p += PageAddress.SIZE; source.ReadPageAddress(p).Should().Be(new PageAddress(199, 0)); p += PageAddress.SIZE; }
public void Buffer_Write_Types() { var source = new BufferSlice(new byte[1000], 0, 1000); var g = Guid.NewGuid(); var d = DateTime.Now; var o = ObjectId.NewObjectId(); using (var w = new BufferWriter(source)) { w.Write(true); w.Write(false); w.Write(DateTime.MinValue); w.Write(DateTime.MaxValue); w.Write(d); w.Write(Guid.Empty); w.Write(g); w.Write(ObjectId.Empty); w.Write(o); w.Write(PageAddress.Empty); w.Write(new PageAddress(199, 0)); } var p = 0; Assert.AreEqual(true, source.ReadBool(p)); p += 1; Assert.AreEqual(false, source.ReadBool(p)); p += 1; Assert.AreEqual(DateTime.MinValue, source.ReadDateTime(p)); p += 8; Assert.AreEqual(DateTime.MaxValue, source.ReadDateTime(p)); p += 8; Assert.AreEqual(d, source.ReadDateTime(p)); p += 8; Assert.AreEqual(Guid.Empty, source.ReadGuid(p)); p += 16; Assert.AreEqual(g, source.ReadGuid(p)); p += 16; Assert.AreEqual(ObjectId.Empty, source.ReadObjectId(p)); p += 12; Assert.AreEqual(o, source.ReadObjectId(p)); p += 12; Assert.AreEqual(PageAddress.Empty, source.ReadPageAddress(p)); p += PageAddress.SIZE; Assert.AreEqual(new PageAddress(199, 0), source.ReadPageAddress(p)); p += PageAddress.SIZE; }