public void ReadInt32_should_return_expected_result( [Values(-1, 0, 1, int.MaxValue, int.MinValue)] int value) { var bytes = BitConverter.GetBytes(value); var stream = new MemoryStream(bytes); var subject = new BsonStreamAdapter(stream); var result = subject.ReadInt32(); result.Should().Be(value); subject.Position.Should().Be(4); }
public void ReadInt32_should_throw_when_subject_is_disposed() { var stream = Substitute.For<Stream>(); var subject = new BsonStreamAdapter(stream); subject.Dispose(); Action action = () => subject.ReadInt32(); action.ShouldThrow<ObjectDisposedException>().And.ObjectName.Should().Be("BsonStreamAdapter"); }
public void ReadInt32_should_be_little_endian() { var bytes = new byte[] { 1, 2, 3, 4 }; var stream = new MemoryStream(bytes); var subject = new BsonStreamAdapter(stream); var result = subject.ReadInt32(); result.Should().Be(0x04030201); }