Inheritance: MongoException
 public void Constructor_with_2_arguments_should_work()
 {
     var query = new BsonDocument("query", 1);
     var exception = new MongoQueryException("message", query);
     exception.Message.Should().Be("message");
     exception.InnerException.Should().BeNull();
     exception.Query.Equals(query).Should().BeTrue();
     exception.QueryResult.Should().BeNull();
 }
Ejemplo n.º 2
0
        public void constructor_should_initialize_subject()
        {
            var subject = new MongoQueryException(_connectionId, _message, _query, _queryResult);

            subject.ConnectionId.Should().BeSameAs(_connectionId);
            subject.InnerException.Should().BeNull();
            subject.Message.Should().Be(_message);
            subject.Query.Should().Be(_query);
            subject.QueryResult.Should().Be(_queryResult);
        }
        public void constructor_should_initialize_subject()
        {
            var subject = new MongoQueryException(_connectionId, _message, _query, _queryResult);

            subject.ConnectionId.Should().BeSameAs(_connectionId);
            subject.InnerException.Should().BeNull();
            subject.Message.Should().Be(_message);
            subject.Query.Should().Be(_query);
            subject.QueryResult.Should().Be(_queryResult);
        }
 public void Constructor_with_4_arguments_should_work()
 {
     var query = new BsonDocument("query", 1);
     var result = new BsonDocument("result", 2);
     var innerException = new Exception("inner");
     var exception = new MongoQueryException("message", query, result, innerException);
     exception.Message.Should().Be("message");
     exception.InnerException.Message.Should().Be("inner");
     exception.Query.Equals(query).Should().BeTrue();
     exception.QueryResult.Equals(result).Should().BeTrue();
 }
        public void Serialization_should_work()
        {
            var subject = new MongoQueryException(_connectionId, _message, _query, _queryResult);

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

                rehydrated.ConnectionId.Should().Be(subject.ConnectionId);
                rehydrated.InnerException.Should().BeNull();
                rehydrated.Message.Should().Be(subject.Message);
                rehydrated.Query.Should().Be(subject.Query);
                rehydrated.QueryResult.Should().Be(subject.QueryResult);
            }
        }
Ejemplo n.º 8
0
        public void Serialization_should_work()
        {
            var subject = new MongoQueryException(_connectionId, _message, _query, _queryResult);

            var formatter = new BinaryFormatter();

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

                rehydrated.ConnectionId.Should().Be(subject.ConnectionId);
                rehydrated.InnerException.Should().BeNull();
                rehydrated.Message.Should().Be(subject.Message);
                rehydrated.Query.Should().Be(subject.Query);
                rehydrated.QueryResult.Should().Be(subject.QueryResult);
            }
        }
        public void Serialization_should_work()
        {
            var query = new BsonDocument("query", 1);
            var result = new BsonDocument("result", 2);
            var innerException = new Exception("inner");
            var exception = new MongoQueryException("message", query, result, innerException);

            var formatter = new BinaryFormatter();
            using (var stream = new MemoryStream())
            {
                formatter.Serialize(stream, exception);
                stream.Position = 0;
                var rehydrated = (MongoQueryException)formatter.Deserialize(stream);
                rehydrated.Message.Should().Be("message");
                rehydrated.InnerException.Message.Should().Be("inner");
                rehydrated.Query.Equals(query).Should().BeTrue();
                rehydrated.QueryResult.Equals(result).Should().BeTrue();
            }
        }