public void PipelineStageDefinitionBuilder_GroupForLinq3_with_expressions_should_throw_with_LINQ2() { var(groupStageDefinition, projectStageDefinition) = PipelineStageDefinitionBuilder.GroupForLinq3((BsonDocument x) => 1, x => new { Count = x.Count() }); var exception = Record.Exception(() => Linq3TestHelpers.Render(groupStageDefinition, BsonDocumentSerializer.Instance, LinqProvider.V2)); exception.Should().BeOfType <InvalidOperationException>(); }
public void PipelineDefinitionBuilder_GroupForLinq3_with_expressions_should_throw_with_LINQ2() { var emptyPipeline = (PipelineDefinition <BsonDocument, BsonDocument>) new EmptyPipelineDefinition <BsonDocument>(); var pipeline = emptyPipeline.GroupForLinq3(x => 1, x => new { Count = x.Count() }); var exception = Record.Exception(() => Linq3TestHelpers.Render(pipeline, BsonDocumentSerializer.Instance, LinqProvider.V2)); exception.Should().BeOfType <InvalidOperationException>(); }
public void PipelineStageDefinitionBuilder_Group_with_expressions_should_work_with_LINQ2() { var stageDefinition = PipelineStageDefinitionBuilder.Group((BsonDocument x) => 1, x => new { Count = x.Count() }); var stage = Linq3TestHelpers.Render(stageDefinition, BsonDocumentSerializer.Instance, LinqProvider.V2); var expectedStages = new[] { "{ $group : { _id : 1, Count : { $sum : 1 } } }" }; Linq3TestHelpers.AssertStages(new[] { stage }, expectedStages); }
public void PipelineStageDefinitionBuilder_Group_with_projection_to_TOutput_should_work( [Values(LinqProvider.V2, LinqProvider.V3)] LinqProvider linqProvider) { var stageDefinition = PipelineStageDefinitionBuilder.Group <BsonDocument, BsonDocument>("{ _id : 1, Count : { $sum : 1 } }"); var stage = Linq3TestHelpers.Render(stageDefinition, BsonDocumentSerializer.Instance, linqProvider); var expectedStages = new[] { "{ $group : { _id : 1, Count : { $sum : 1 } } }" }; Linq3TestHelpers.AssertStages(new[] { stage }, expectedStages); }
public void PipelineDefinitionBuilder_Group_with_expressions_should_work_with_LINQ2() { var emptyPipeline = (PipelineDefinition <BsonDocument, BsonDocument>) new EmptyPipelineDefinition <BsonDocument>(); var pipeline = emptyPipeline.Group(x => 1, x => new { Count = x.Count() }); var stages = Linq3TestHelpers.Render(pipeline, BsonDocumentSerializer.Instance, LinqProvider.V2); var expectedStages = new[] { "{ $group : { _id : 1, Count : { $sum : 1 } } }" }; Linq3TestHelpers.AssertStages(stages, expectedStages); }
public void PipelineDefinitionBuilder_Group_with_projection_to_implied_BsonDocument_should_work( [Values(LinqProvider.V2, LinqProvider.V3)] LinqProvider linqProvider) { var emptyPipeline = (PipelineDefinition <BsonDocument, BsonDocument>) new EmptyPipelineDefinition <BsonDocument>(); var pipeline = emptyPipeline.Group("{ _id : 1, Count : { $sum : 1 } }"); var stages = Linq3TestHelpers.Render(pipeline, BsonDocumentSerializer.Instance, linqProvider); var expectedStages = new[] { "{ $group : { _id : 1, Count : { $sum : 1 } } }" }; Linq3TestHelpers.AssertStages(stages, expectedStages); }
public void PipelineStageDefinitionBuilderGroupForLinq3_with_expressions_should_work_with_LINQ3() { var(groupStageDefinition, projectStageDefinition) = PipelineStageDefinitionBuilder.GroupForLinq3((BsonDocument x) => 1, x => new { Count = x.Count() }); var groupStage = Linq3TestHelpers.Render(groupStageDefinition, BsonDocumentSerializer.Instance, LinqProvider.V3); var groupingSerializer = new IGroupingSerializer <int, BsonDocument>(new Int32Serializer(), BsonDocumentSerializer.Instance); var projectStage = Linq3TestHelpers.Render(projectStageDefinition, groupingSerializer, LinqProvider.V3); var expectedStages = new[] { "{ $group : { _id : 1, __agg0 : { $sum : 1 } } }", "{ $project : { Count : '$__agg0', _id : 0 } }" }; Linq3TestHelpers.AssertStages(new[] { groupStage, projectStage }, expectedStages); }