1
+ /* Copyright 2010-2014 MongoDB Inc.
2
+ *
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ using System . Threading ;
17
+ using System . Threading . Tasks ;
18
+ using FluentAssertions ;
19
+ using MongoDB . Bson ;
20
+ using NSubstitute ;
21
+ using NUnit . Framework ;
22
+
23
+ namespace MongoDB . Driver . Tests
24
+ {
25
+ [ TestFixture ]
26
+ public class FindFluentTests
27
+ {
28
+ private IMongoCollection < Person > _collection ;
29
+
30
+ [ Test ]
31
+ public void CountAsync_should_not_throw_a_null_reference_exception ( )
32
+ {
33
+ var subject = CreateSubject ( ) ;
34
+
35
+ var result = subject . CountAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
36
+
37
+ _collection . Received ( ) . CountAsync (
38
+ subject . Filter ,
39
+ Arg . Any < CountOptions > ( ) ,
40
+ Arg . Any < CancellationToken > ( ) ) ;
41
+ }
42
+
43
+ private IFindFluent < Person , Person > CreateSubject ( )
44
+ {
45
+ var settings = new MongoCollectionSettings ( ) ;
46
+ _collection = Substitute . For < IMongoCollection < Person > > ( ) ;
47
+ _collection . Settings . Returns ( settings ) ;
48
+ var options = new FindOptions < Person , Person > ( ) ;
49
+ var subject = new FindFluent < Person , Person > ( _collection , new BsonDocument ( ) , options ) ;
50
+
51
+ return subject ;
52
+ }
53
+
54
+ public class Person
55
+ {
56
+ public string FirstName ;
57
+ public string LastName ;
58
+ public int Age ;
59
+ }
60
+ }
61
+ }
0 commit comments