コード例 #1
0
        private IFindFluent <Person, Person> CreateSubject(IClientSessionHandle session = null, FilterDefinition <Person> filter = null, FindOptions <Person, Person> options = null)
        {
            var clientSettings = new MongoClientSettings {
                LinqProvider = LinqProvider.V2
            };
            var mockClient = new Mock <IMongoClient>();

            mockClient.SetupGet(c => c.Settings).Returns(clientSettings);

            var mockDatabase = new Mock <IMongoDatabase>();

            mockDatabase.SetupGet(d => d.Client).Returns(mockClient.Object);

            var collectionSettings = new MongoCollectionSettings();

            _mockCollection = new Mock <IMongoCollection <Person> >();
            _mockCollection.SetupGet(c => c.Database).Returns(mockDatabase.Object);
            _mockCollection.SetupGet(c => c.DocumentSerializer).Returns(BsonSerializer.SerializerRegistry.GetSerializer <Person>());
            _mockCollection.SetupGet(c => c.Settings).Returns(collectionSettings);
            filter  = filter ?? new BsonDocument();
            options = options ?? new FindOptions <Person, Person>();
            var subject = new FindFluent <Person, Person>(session: session, collection: _mockCollection.Object, filter: filter, options: options);

            return(subject);
        }
コード例 #2
0
        private IFindFluent<Person, Person> CreateSubject()
        {
            var settings = new MongoCollectionSettings();
            _collection = Substitute.For<IMongoCollection<Person>>();
            _collection.DocumentSerializer.Returns(BsonSerializer.SerializerRegistry.GetSerializer<Person>());
            _collection.Settings.Returns(settings);
            var options = new FindOptions<Person, Person>();
            var subject = new FindFluent<Person, Person>(_collection, new BsonDocument(), options);

            return subject;
        }
コード例 #3
0
        private IFindFluent <Person, Person> CreateSubject()
        {
            var settings   = new MongoCollectionSettings();
            var collection = Substitute.For <IMongoCollection <Person> >();

            collection.Settings.Returns(settings);
            var options = new FindOptions <Person>();
            var subject = new FindFluent <Person, Person>(collection, new BsonDocument(), options);

            return(subject);
        }
コード例 #4
0
        private IFindFluent <Person, Person> CreateSubject()
        {
            var settings = new MongoCollectionSettings();

            _collection = Substitute.For <IMongoCollection <Person> >();
            _collection.DocumentSerializer.Returns(BsonSerializer.SerializerRegistry.GetSerializer <Person>());
            _collection.Settings.Returns(settings);
            var options = new FindOptions <Person, Person>();
            var subject = new FindFluent <Person, Person>(_collection, new BsonDocument(), options);

            return(subject);
        }
コード例 #5
0
        private IFindFluent <Person, Person> CreateSubject(FindOptions <Person, Person> options = null)
        {
            var settings = new MongoCollectionSettings();

            _mockCollection = new Mock <IMongoCollection <Person> >();
            _mockCollection.SetupGet(c => c.DocumentSerializer).Returns(BsonSerializer.SerializerRegistry.GetSerializer <Person>());
            _mockCollection.SetupGet(c => c.Settings).Returns(settings);
            options = options ?? new FindOptions <Person, Person>();
            var subject = new FindFluent <Person, Person>(_mockCollection.Object, new BsonDocument(), options);

            return(subject);
        }
コード例 #6
0
        private IFindFluent <Person, Person> CreateSubject(IClientSessionHandle session = null, FilterDefinition <Person> filter = null, FindOptions <Person, Person> options = null)
        {
            var settings = new MongoCollectionSettings();

            _mockCollection = new Mock <IMongoCollection <Person> >();
            _mockCollection.SetupGet(c => c.DocumentSerializer).Returns(BsonSerializer.SerializerRegistry.GetSerializer <Person>());
            _mockCollection.SetupGet(c => c.Settings).Returns(settings);
            filter  = filter ?? new BsonDocument();
            options = options ?? new FindOptions <Person, Person>();
            var subject = new FindFluent <Person, Person>(session: session, collection: _mockCollection.Object, filter: filter, options: options);

            return(subject);
        }
コード例 #7
0
        public static IClientSessionHandle _session <TDocument, TProjection>(this FindFluent <TDocument, TProjection> obj)
        {
            var fieldInfo = typeof(FindFluent <TDocument, TProjection>).GetField("_session", BindingFlags.NonPublic | BindingFlags.Instance);

            return((IClientSessionHandle)fieldInfo.GetValue(obj));
        }
コード例 #8
0
        public static FindOptions <TDocument, TProjection> _options <TDocument, TProjection>(this FindFluent <TDocument, TProjection> obj)
        {
            var fieldInfo = typeof(FindFluent <TDocument, TProjection>).GetField("_options", BindingFlags.NonPublic | BindingFlags.Instance);

            return((FindOptions <TDocument, TProjection>)fieldInfo.GetValue(obj));
        }
コード例 #9
0
        public static FilterDefinition <TDocument> _filter <TDocument, TProjection>(this FindFluent <TDocument, TProjection> obj)
        {
            var fieldInfo = typeof(FindFluent <TDocument, TProjection>).GetField("_filter", BindingFlags.NonPublic | BindingFlags.Instance);

            return((FilterDefinition <TDocument>)fieldInfo.GetValue(obj));
        }
コード例 #10
0
        public static IMongoCollection <TDocument> _collection <TDocument, TProjection>(this FindFluent <TDocument, TProjection> obj)
        {
            var fieldInfo = typeof(FindFluent <TDocument, TProjection>).GetField("_collection", BindingFlags.NonPublic | BindingFlags.Instance);

            return((IMongoCollection <TDocument>)fieldInfo.GetValue(obj));
        }
コード例 #11
0
ファイル: FindFluentTests.cs プロジェクト: RavenZZ/MDRelation
        private IFindFluent<Person, Person> CreateSubject(FindOptions<Person, Person> options = null)
        {
            var settings = new MongoCollectionSettings();
            _mockCollection = new Mock<IMongoCollection<Person>>();
            _mockCollection.SetupGet(c => c.DocumentSerializer).Returns(BsonSerializer.SerializerRegistry.GetSerializer<Person>());
            _mockCollection.SetupGet(c => c.Settings).Returns(settings);
            options = options ?? new FindOptions<Person, Person>();
            var subject = new FindFluent<Person, Person>(_mockCollection.Object, new BsonDocument(), options);

            return subject;
        }