public void Merge_with_default_options_should_return_the_expected_result(string outputDatabaseName, string outputCollectionName, string expectedStage) { var client = DriverTestConfiguration.Client; var outputDatabase = client.GetDatabase(outputDatabaseName); var outputCollection = outputDatabase.GetCollection <BsonDocument>(outputCollectionName); var mergeOptions = new MergeStageOptions <BsonDocument>(); var result = PipelineStageDefinitionBuilder.Merge <BsonDocument, BsonDocument>(outputCollection, mergeOptions); var stage = RenderStage(result); stage.Document.Should().Be(expectedStage); }
public void Merge_with_WhenNotMatched_should_return_the_expected_result(MergeStageWhenNotMatched whenNotMatched, string expectedStage) { var client = DriverTestConfiguration.Client; var outputDatabase = client.GetDatabase("database"); var outputCollection = outputDatabase.GetCollection <BsonDocument>("collection"); var mergeOptions = new MergeStageOptions <BsonDocument> { WhenNotMatched = whenNotMatched }; var result = PipelineStageDefinitionBuilder.Merge <BsonDocument, BsonDocument>(outputCollection, mergeOptions); var stage = RenderStage(result); stage.Document.Should().Be(expectedStage); }
public void Merge_with_OnFieldNames_should_return_the_expected_result(string fieldNames, string expectedStage) { var client = DriverTestConfiguration.Client; var outputDatabase = client.GetDatabase("database"); var outputCollection = outputDatabase.GetCollection <BsonDocument>("collection"); var mergeOptions = new MergeStageOptions <BsonDocument> { OnFieldNames = fieldNames.Split(',') }; var result = PipelineStageDefinitionBuilder.Merge <BsonDocument, BsonDocument>(outputCollection, mergeOptions); var stage = RenderStage(result); stage.Document.Should().Be(expectedStage); }
public void Merge_with_LetVariables_should_return_the_expected_result(string letVariables, string expectedStage) { var client = DriverTestConfiguration.Client; var outputDatabase = client.GetDatabase("database"); var outputCollection = outputDatabase.GetCollection <BsonDocument>("collection"); var mergeOptions = new MergeStageOptions <BsonDocument> { LetVariables = BsonDocument.Parse(letVariables), WhenMatched = MergeStageWhenMatched.Pipeline, WhenMatchedPipeline = new EmptyPipelineDefinition <BsonDocument>().Project("{ _id : '$_id' }") }; var result = PipelineStageDefinitionBuilder.Merge <BsonDocument, BsonDocument>(outputCollection, mergeOptions); var stage = RenderStage(result); stage.Document.Should().Be(expectedStage); }