public void UnionWith_should_throw_when_withCollection_is_null() { var pipeline = new EmptyPipelineDefinition <BsonDocument>(); IMongoCollection <BsonDocument> withCollection = null; var withPipeline = new EmptyPipelineDefinition <BsonDocument>(); var exception = Record.Exception(() => pipeline.UnionWith(withCollection, withPipeline)); var argumentNullException = exception.Should().BeOfType <ArgumentNullException>().Subject; argumentNullException.ParamName.Should().Be("withCollection"); }
public void UnionWith_should_throw_when_TWith_is_not_the_same_with_TInput_and_withPipeline_is_null() { var pipeline = new EmptyPipelineDefinition <BsonDocument>(); var withCollection = Mock.Of <IMongoCollection <object> >( coll => coll.CollectionNamespace == CollectionNamespace.FromFullName("db.test")); var exception = Record.Exception(() => pipeline.UnionWith(withCollection, withPipeline: null)); var e = exception.Should().BeOfType <ArgumentException>().Subject; e.Message.Should().StartWith("The withPipeline cannot be null when TWith != TInput. A pipeline is required to transform the TWith documents to TInput documents."); e.ParamName.Should().Be("withPipeline"); }
public void UnionWith_should_add_expected_stage() { var pipeline = new EmptyPipelineDefinition <BsonDocument>(); var withCollection = Mock.Of <IMongoCollection <BsonDocument> >( coll => coll.CollectionNamespace == CollectionNamespace.FromFullName("db.test")); var withPipeline = new EmptyPipelineDefinition <BsonDocument>() .AppendStage <BsonDocument, BsonDocument, BsonDocument>("{ $match : { b : 1 } }"); var result = pipeline.UnionWith(withCollection, withPipeline); var stages = RenderStages(result, BsonDocumentSerializer.Instance); stages[0].Should().Be("{ $unionWith : { coll : 'test', pipeline : [{ $match : { b : 1 } }] } }"); }