public void constructor_should_initalize_subject() { var subject = new MongoCursorNotFoundException(_connectionId, _cursorId, _query); subject.ConnectionId.Should().BeSameAs(_connectionId); subject.CursorId.Should().Be(_cursorId); subject.InnerException.Should().BeNull(); subject.Message.Should().StartWith("Cursor 1 not found"); subject.Message.Should().Contain("server localhost:27017"); subject.Message.Should().Contain("connection 2"); subject.Query.Should().BeSameAs(_query); subject.QueryResult.Should().BeNull(); }
public void Serialization_should_work() { var subject = new MongoCursorNotFoundException(_connectionId, _cursorId, _query); var formatter = new BinaryFormatter(); using (var stream = new MemoryStream()) { formatter.Serialize(stream, subject); stream.Position = 0; var rehydrated = (MongoCursorNotFoundException)formatter.Deserialize(stream); rehydrated.ConnectionId.Should().Be(subject.ConnectionId); rehydrated.CursorId.Should().Be(subject.CursorId); rehydrated.InnerException.Should().BeNull(); rehydrated.Message.Should().Be(subject.Message); rehydrated.Query.Should().Be(subject.Query); rehydrated.QueryResult.Should().Be(subject.QueryResult); } }