コード例 #1
0
        public void constructor_with_innerException_should_initialize_subject()
        {
            var subject = new MongoExecutionTimeoutException(_connectionId, _message, _innerException);

            subject.ConnectionId.Should().BeSameAs(_connectionId);
            subject.InnerException.Should().BeSameAs(_innerException);
            subject.Message.Should().BeSameAs(_message);
        }
        public void constructor_with_innerException_should_initialize_subject()
        {
            var subject = new MongoExecutionTimeoutException(_connectionId, _message, _innerException);

            subject.ConnectionId.Should().BeSameAs(_connectionId);
            subject.InnerException.Should().BeSameAs(_innerException);
            subject.Message.Should().BeSameAs(_message);
        }
        public void Serialization_should_work()
        {
            var subject = new MongoExecutionTimeoutException(_connectionId, _message, _innerException);

            var formatter = new BinaryFormatter();
            using (var stream = new MemoryStream())
            {
                formatter.Serialize(stream, subject);
                stream.Position = 0;
                var rehydrated = (MongoExecutionTimeoutException)formatter.Deserialize(stream);

                rehydrated.ConnectionId.Should().Be(subject.ConnectionId);
                rehydrated.Message.Should().Be(subject.Message);
                rehydrated.InnerException.Message.Should().Be(subject.InnerException.Message); // Exception does not override Equals
            }
        }
コード例 #4
0
        public void Serialization_should_work()
        {
            var subject = new MongoExecutionTimeoutException(_connectionId, _message, _innerException);

            var formatter = new BinaryFormatter();

            using (var stream = new MemoryStream())
            {
                formatter.Serialize(stream, subject);
                stream.Position = 0;
                var rehydrated = (MongoExecutionTimeoutException)formatter.Deserialize(stream);

                rehydrated.ConnectionId.Should().Be(subject.ConnectionId);
                rehydrated.Message.Should().Be(subject.Message);
                rehydrated.InnerException.Message.Should().Be(subject.InnerException.Message); // Exception does not override Equals
            }
        }
コード例 #5
0
        public void Serialization_should_work()
        {
            var subject = new MongoExecutionTimeoutException(_connectionId, _message, _innerException, new BsonDocument("code", 1234));

            var formatter = new BinaryFormatter();

            using (var stream = new MemoryStream())
            {
                formatter.Serialize(stream, subject);
                stream.Position = 0;
                var rehydrated = (MongoExecutionTimeoutException)formatter.Deserialize(stream);

                rehydrated.Code.Should().Be(subject.Code);
                rehydrated.ConnectionId.Should().Be(subject.ConnectionId);
                rehydrated.InnerException.Message.Should().Be(subject.InnerException.Message);
                rehydrated.Message.Should().Be(subject.Message);
            }
        }