Skip to content

Commit

Permalink
CSHARP-1845: Skip tests that require text commands to be enabled on 2.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
rstam committed Feb 16, 2017
1 parent 2a62df6 commit 8641f80
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
30 changes: 14 additions & 16 deletions tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTests.cs
@@ -1,4 +1,4 @@
/* Copyright 2010-2016 MongoDB Inc.
/* Copyright 2010-2017 MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,8 +16,11 @@
using System;
using System.Linq;
using MongoDB.Bson;
using MongoDB.Bson.TestHelpers.XunitExtensions;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
using MongoDB.Driver.Core.Clusters;
using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
using Xunit;

namespace MongoDB.Driver.Tests.Builders
Expand Down Expand Up @@ -203,23 +206,18 @@ public void TestTextCombination()
Assert.Equal(expected, key.ToJson());
}

[Fact]
[SkippableFact]
public void TestTextIndexCreation()
{
if (_primary.InstanceType != MongoServerInstanceType.ShardRouter)
{
if (_primary.Supports(FeatureId.TextSearchCommand))
{
var collection = _database.GetCollection<BsonDocument>("test_text");
collection.Drop();
collection.CreateIndex(IndexKeys.Text("a", "b").Ascending("c"), IndexOptions.SetTextLanguageOverride("idioma").SetName("custom").SetTextDefaultLanguage("spanish"));
var indexes = collection.GetIndexes();
var index = indexes.RawDocuments.Single(i => i["name"].AsString == "custom");
Assert.Equal("idioma", index["language_override"].AsString);
Assert.Equal("spanish", index["default_language"].AsString);
Assert.Equal(1, index["key"]["c"].AsInt32);
}
}
RequireServer.Check().VersionGreaterThanOrEqualTo("2.6.0").ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet);
var collection = _database.GetCollection<BsonDocument>("test_text");
collection.Drop();
collection.CreateIndex(IndexKeys.Text("a", "b").Ascending("c"), IndexOptions.SetTextLanguageOverride("idioma").SetName("custom").SetTextDefaultLanguage("spanish"));
var indexes = collection.GetIndexes();
var index = indexes.RawDocuments.Single(i => i["name"].AsString == "custom");
Assert.Equal("idioma", index["language_override"].AsString);
Assert.Equal("spanish", index["default_language"].AsString);
Assert.Equal(1, index["key"]["c"].AsInt32);
}
}
}
@@ -1,4 +1,4 @@
/* Copyright 2010-2016 MongoDB Inc.
/* Copyright 2010-2017 MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,8 +18,11 @@
using System.Linq;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.TestHelpers.XunitExtensions;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
using MongoDB.Driver.Core.Clusters;
using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
using Xunit;

namespace MongoDB.Driver.Tests.Builders
Expand Down Expand Up @@ -254,23 +257,18 @@ public void TestTextArrayNonArrayFields2()
Assert.Equal(expected, keys.ToJson());
}

[Fact]
[SkippableFact]
public void TestTextIndexCreation()
{
if (_primary.InstanceType != MongoServerInstanceType.ShardRouter)
{
if (_primary.Supports(FeatureId.TextSearchCommand))
{
var collection = _database.GetCollection<Test>("test_text");
collection.Drop();
collection.CreateIndex(IndexKeys<Test>.Text(x => x.A, x => x.B).Ascending(x => x.C), IndexOptions.SetTextLanguageOverride("idioma").SetName("custom").SetTextDefaultLanguage("spanish"));
var indexes = collection.GetIndexes();
var index = indexes.RawDocuments.Single(i => i["name"].AsString == "custom");
Assert.Equal("idioma", index["language_override"].AsString);
Assert.Equal("spanish", index["default_language"].AsString);
Assert.Equal(1, index["key"]["c"].AsInt32);
}
}
RequireServer.Check().VersionGreaterThanOrEqualTo("2.6.0").ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet);
var collection = _database.GetCollection<Test>("test_text");
collection.Drop();
collection.CreateIndex(IndexKeys<Test>.Text(x => x.A, x => x.B).Ascending(x => x.C), IndexOptions.SetTextLanguageOverride("idioma").SetName("custom").SetTextDefaultLanguage("spanish"));
var indexes = collection.GetIndexes();
var index = indexes.RawDocuments.Single(i => i["name"].AsString == "custom");
Assert.Equal("idioma", index["language_override"].AsString);
Assert.Equal("spanish", index["default_language"].AsString);
Assert.Equal(1, index["key"]["c"].AsInt32);
}
}
}

0 comments on commit 8641f80

Please sign in to comment.