@@ -44,6 +44,7 @@ public ExplainTests()
44
44
[ Fact ]
45
45
public void TestExplainFromLinqQueryEqualsExplainFromCursor ( )
46
46
{
47
+ EnsureCollectionExists ( ) ;
47
48
var linqExplain = _collection . AsQueryable < C > ( ) . Where ( c => c . X == 2 && c . Y == 1 ) . Take ( 1 ) . Explain ( ) ;
48
49
var queryExplain = _collection . FindAs < C > ( Query . And ( Query . EQ ( "X" , 2 ) , Query . EQ ( "Y" , 1 ) ) ) . SetLimit ( 1 ) . Explain ( ) ;
49
50
@@ -63,6 +64,7 @@ public void TestExplainFromLinqQueryEqualsExplainFromCursor()
63
64
[ Fact ]
64
65
public void TestVerboseExplainFromLinqQueryEqualsVerboseExplainFromCursor ( )
65
66
{
67
+ EnsureCollectionExists ( ) ;
66
68
var linqExplain = _collection . AsQueryable < C > ( ) . Where ( c => c . X == 2 && c . Y == 1 ) . Take ( 1 ) . Explain ( true ) ;
67
69
var queryExplain = _collection . FindAs < C > ( Query . And ( Query . EQ ( "X" , 2 ) , Query . EQ ( "Y" , 1 ) ) ) . SetLimit ( 1 ) . Explain ( true ) ;
68
70
@@ -82,6 +84,7 @@ public void TestVerboseExplainFromLinqQueryEqualsVerboseExplainFromCursor()
82
84
[ Fact ]
83
85
public void TestDistinctQueryCannotBeExplained ( )
84
86
{
87
+ EnsureCollectionExists ( ) ;
85
88
Assert . Throws < NotSupportedException > ( ( ) => _collection . AsQueryable < C > ( ) . Select ( c=> c . X ) . Distinct ( ) . Explain ( ) ) ;
86
89
}
87
90
@@ -91,6 +94,13 @@ public void TestTakeZeroQueriesCannotBeExplained()
91
94
Assert . Throws < NotSupportedException > ( ( ) => _collection . AsQueryable < C > ( ) . Take ( 0 ) . Explain ( ) ) ;
92
95
}
93
96
97
+ // private methods
98
+ private void EnsureCollectionExists ( )
99
+ {
100
+ var document = new BsonDocument ( "x" , 1 ) ;
101
+ _collection . Insert ( document ) ;
102
+ }
103
+
94
104
private void RemoveMatchingElements ( BsonValue value , Regex regex )
95
105
{
96
106
if ( value . BsonType == BsonType . Document )
0 commit comments