Skip to content

Commit 8641f80

Browse files
committed
CSHARP-1845: Skip tests that require text commands to be enabled on 2.4.
1 parent 2a62df6 commit 8641f80

File tree

2 files changed

+28
-32
lines changed

2 files changed

+28
-32
lines changed

tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTests.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2010-2016 MongoDB Inc.
1+
/* Copyright 2010-2017 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -16,8 +16,11 @@
1616
using System;
1717
using System.Linq;
1818
using MongoDB.Bson;
19+
using MongoDB.Bson.TestHelpers.XunitExtensions;
1920
using MongoDB.Driver;
2021
using MongoDB.Driver.Builders;
22+
using MongoDB.Driver.Core.Clusters;
23+
using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
2124
using Xunit;
2225

2326
namespace MongoDB.Driver.Tests.Builders
@@ -203,23 +206,18 @@ public void TestTextCombination()
203206
Assert.Equal(expected, key.ToJson());
204207
}
205208

206-
[Fact]
209+
[SkippableFact]
207210
public void TestTextIndexCreation()
208211
{
209-
if (_primary.InstanceType != MongoServerInstanceType.ShardRouter)
210-
{
211-
if (_primary.Supports(FeatureId.TextSearchCommand))
212-
{
213-
var collection = _database.GetCollection<BsonDocument>("test_text");
214-
collection.Drop();
215-
collection.CreateIndex(IndexKeys.Text("a", "b").Ascending("c"), IndexOptions.SetTextLanguageOverride("idioma").SetName("custom").SetTextDefaultLanguage("spanish"));
216-
var indexes = collection.GetIndexes();
217-
var index = indexes.RawDocuments.Single(i => i["name"].AsString == "custom");
218-
Assert.Equal("idioma", index["language_override"].AsString);
219-
Assert.Equal("spanish", index["default_language"].AsString);
220-
Assert.Equal(1, index["key"]["c"].AsInt32);
221-
}
222-
}
212+
RequireServer.Check().VersionGreaterThanOrEqualTo("2.6.0").ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet);
213+
var collection = _database.GetCollection<BsonDocument>("test_text");
214+
collection.Drop();
215+
collection.CreateIndex(IndexKeys.Text("a", "b").Ascending("c"), IndexOptions.SetTextLanguageOverride("idioma").SetName("custom").SetTextDefaultLanguage("spanish"));
216+
var indexes = collection.GetIndexes();
217+
var index = indexes.RawDocuments.Single(i => i["name"].AsString == "custom");
218+
Assert.Equal("idioma", index["language_override"].AsString);
219+
Assert.Equal("spanish", index["default_language"].AsString);
220+
Assert.Equal(1, index["key"]["c"].AsInt32);
223221
}
224222
}
225223
}

tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTypedTests.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2010-2016 MongoDB Inc.
1+
/* Copyright 2010-2017 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -18,8 +18,11 @@
1818
using System.Linq;
1919
using MongoDB.Bson;
2020
using MongoDB.Bson.Serialization.Attributes;
21+
using MongoDB.Bson.TestHelpers.XunitExtensions;
2122
using MongoDB.Driver;
2223
using MongoDB.Driver.Builders;
24+
using MongoDB.Driver.Core.Clusters;
25+
using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
2326
using Xunit;
2427

2528
namespace MongoDB.Driver.Tests.Builders
@@ -254,23 +257,18 @@ public void TestTextArrayNonArrayFields2()
254257
Assert.Equal(expected, keys.ToJson());
255258
}
256259

257-
[Fact]
260+
[SkippableFact]
258261
public void TestTextIndexCreation()
259262
{
260-
if (_primary.InstanceType != MongoServerInstanceType.ShardRouter)
261-
{
262-
if (_primary.Supports(FeatureId.TextSearchCommand))
263-
{
264-
var collection = _database.GetCollection<Test>("test_text");
265-
collection.Drop();
266-
collection.CreateIndex(IndexKeys<Test>.Text(x => x.A, x => x.B).Ascending(x => x.C), IndexOptions.SetTextLanguageOverride("idioma").SetName("custom").SetTextDefaultLanguage("spanish"));
267-
var indexes = collection.GetIndexes();
268-
var index = indexes.RawDocuments.Single(i => i["name"].AsString == "custom");
269-
Assert.Equal("idioma", index["language_override"].AsString);
270-
Assert.Equal("spanish", index["default_language"].AsString);
271-
Assert.Equal(1, index["key"]["c"].AsInt32);
272-
}
273-
}
263+
RequireServer.Check().VersionGreaterThanOrEqualTo("2.6.0").ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet);
264+
var collection = _database.GetCollection<Test>("test_text");
265+
collection.Drop();
266+
collection.CreateIndex(IndexKeys<Test>.Text(x => x.A, x => x.B).Ascending(x => x.C), IndexOptions.SetTextLanguageOverride("idioma").SetName("custom").SetTextDefaultLanguage("spanish"));
267+
var indexes = collection.GetIndexes();
268+
var index = indexes.RawDocuments.Single(i => i["name"].AsString == "custom");
269+
Assert.Equal("idioma", index["language_override"].AsString);
270+
Assert.Equal("spanish", index["default_language"].AsString);
271+
Assert.Equal(1, index["key"]["c"].AsInt32);
274272
}
275273
}
276274
}

0 commit comments

Comments
 (0)