private void ExecuteOperation(IMongoClient client, IMongoDatabase database, IMongoCollection <BsonDocument> collection, BsonDocument operation, BsonDocument outcome, bool async) { JsonDrivenHelper.EnsureAllFieldsAreValid(operation, "name", "object", "collectionOptions", "arguments", "error", "result"); if (operation.TryGetValue("object", out var @object)) { if (@object.AsString == "database") { collection = null; } } var name = (string)operation["name"]; var test = CrudOperationTestFactory.CreateTest(name); bool isErrorExpected = operation.GetValue("error", false).AsBoolean; var arguments = (BsonDocument)operation.GetValue("arguments", new BsonDocument()); test.SkipIfNotSupported(arguments); if (operation.TryGetValue("result", out var result)) { outcome = outcome ?? new BsonDocument(); outcome["result"] = result; } test.Execute(client.Cluster.Description, database, collection, arguments, outcome, isErrorExpected, async); var threwException = test.ActualException != null; if (isErrorExpected && !threwException) { throw new Exception("The test was expected to throw an exception, but no exception was thrown."); } }
private void ExecuteOperation(IMongoDatabase database, IMongoCollection <BsonDocument> collection, BsonDocument operation, BsonDocument outcome, bool async) { var name = (string)operation["name"]; var test = CrudOperationTestFactory.CreateTest(name); var arguments = (BsonDocument)operation.GetValue("arguments", new BsonDocument()); string reason; if (!test.CanExecute(DriverTestConfiguration.Client.Cluster.Description, arguments, out reason)) { throw new SkipException(reason); } test.Execute(DriverTestConfiguration.Client.Cluster.Description, database, collection, arguments, outcome, async); }
private void ExecuteOperation(IMongoClient client, IMongoDatabase database, IMongoCollection <BsonDocument> collection, BsonDocument operation, BsonDocument outcome, bool async) { var name = (string)operation["name"]; var test = CrudOperationTestFactory.CreateTest(name); bool isErrorExpected = operation.GetValue("error", false).AsBoolean; var arguments = (BsonDocument)operation.GetValue("arguments", new BsonDocument()); test.SkipIfNotSupported(arguments); test.Execute(client.Cluster.Description, database, collection, arguments, outcome, isErrorExpected, async); var threwException = test.ActualException != null; if (isErrorExpected && !threwException) { throw new Exception("The test was expected to throw an exception, but no exception was thrown."); } }