コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }