@@ -44,7 +44,7 @@ private class TestClass
44
44
public void Setup ( )
45
45
{
46
46
_server = Configuration . TestServer ;
47
- _primary = Configuration . TestServer . Primary ;
47
+ _primary = _server . Instances . First ( x => ReadPreference . Primary . MatchesInstance ( x ) ) ;
48
48
_database = Configuration . TestDatabase ;
49
49
_collection = Configuration . TestCollection ;
50
50
}
@@ -1752,7 +1752,7 @@ public void TestGetMore()
1752
1752
using ( _server . RequestStart ( _database ) )
1753
1753
{
1754
1754
_collection . RemoveAll ( ) ;
1755
- var count = _server . Primary . MaxMessageLength / 1000000 ;
1755
+ var count = _primary . MaxMessageLength / 1000000 ;
1756
1756
for ( int i = 0 ; i < count ; i ++ )
1757
1757
{
1758
1758
var document = new BsonDocument ( "data" , new BsonBinaryData ( new byte [ 1000000 ] ) ) ;
@@ -2763,27 +2763,30 @@ public void TestStrictWrite()
2763
2763
}
2764
2764
2765
2765
[ Test ]
2766
- public void TestTextIndex ( )
2766
+ public void TestTextSearch ( )
2767
2767
{
2768
2768
if ( _primary . Supports ( FeatureId . TextSearchCommand ) )
2769
2769
{
2770
- Configuration . EnableTextSearch ( _primary ) ;
2771
- using ( _server . RequestStart ( null , _primary ) )
2770
+ if ( _primary . InstanceType != MongoServerInstanceType . ShardRouter )
2772
2771
{
2773
- _collection . Drop ( ) ;
2774
- _collection . Insert ( new BsonDocument ( "x" , "The quick brown fox" ) ) ;
2775
- _collection . Insert ( new BsonDocument ( "x" , "jumped over the fence" ) ) ;
2776
- _collection . CreateIndex ( IndexKeys . Text ( "x" ) ) ;
2772
+ Configuration . EnableTextSearch ( _primary ) ;
2773
+ using ( _server . RequestStart ( null , _primary ) )
2774
+ {
2775
+ _collection . Drop ( ) ;
2776
+ _collection . Insert ( new BsonDocument ( "x" , "The quick brown fox" ) ) ;
2777
+ _collection . Insert ( new BsonDocument ( "x" , "jumped over the fence" ) ) ;
2778
+ _collection . CreateIndex ( IndexKeys . Text ( "x" ) ) ;
2777
2779
2778
- var textSearchCommand = new CommandDocument
2780
+ var textSearchCommand = new CommandDocument
2779
2781
{
2780
2782
{ "text" , _collection . Name } ,
2781
2783
{ "search" , "fox" }
2782
2784
} ;
2783
- var commandResult = _database . RunCommand ( textSearchCommand ) ;
2784
- var response = commandResult . Response ;
2785
- Assert . AreEqual ( 1 , response [ "stats" ] [ "n" ] . ToInt32 ( ) ) ;
2786
- Assert . AreEqual ( "The quick brown fox" , response [ "results" ] [ 0 ] [ "obj" ] [ "x" ] . AsString ) ;
2785
+ var commandResult = _database . RunCommand ( textSearchCommand ) ;
2786
+ var response = commandResult . Response ;
2787
+ Assert . AreEqual ( 1 , response [ "stats" ] [ "n" ] . ToInt32 ( ) ) ;
2788
+ Assert . AreEqual ( "The quick brown fox" , response [ "results" ] [ 0 ] [ "obj" ] [ "x" ] . AsString ) ;
2789
+ }
2787
2790
}
2788
2791
}
2789
2792
}
0 commit comments