MongoDB.Driver.CommandResult.Initialize C# (CSharp) Method

Initialize() public method

Initializes an existing instance of the CommandResult class.
public Initialize ( IMongoCommand command, BsonDocument response ) : void
command IMongoCommand The command.
response BsonDocument The response.
return void
        public void Initialize(IMongoCommand command, BsonDocument response)
        {
            if (_command != null || _response != null)
            {
                var message = string.Format("{0} has already been initialized.", this.GetType().Name);
                throw new InvalidOperationException(message);
            }
            _command = command;
            _response = response;
        }
    }

Usage Example

 public void TestErrorMessagePresent()
 {
     var document = new BsonDocument("errmsg", "An error message");
     var result = new CommandResult();
     result.Initialize(document);
     Assert.AreEqual("An error message", result.ErrorMessage);
 }
All Usage Examples Of MongoDB.Driver.CommandResult::Initialize