Skip to content

Commit f29d6ac

Browse files
author
rstam
committed
Changed a few unit tests that were failing when run against a replica set.
1 parent cdd29cb commit f29d6ac

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

DriverUnitTests/Core/MongoServerTests.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,29 @@ public void TestGetDatabaseNames()
159159
[Test]
160160
public void TestInstance()
161161
{
162-
var instance = _server.Instance;
163-
Assert.IsNotNull(instance);
164-
Assert.IsTrue(instance.IsPrimary);
162+
if (_server.Instances.Length == 1)
163+
{
164+
var instance = _server.Instance;
165+
Assert.IsNotNull(instance);
166+
Assert.IsTrue(instance.IsPrimary);
167+
}
165168
}
166169

167170
[Test]
168171
public void TestInstances()
169172
{
170173
var instances = _server.Instances;
171174
Assert.IsNotNull(instances);
172-
Assert.AreEqual(1, instances.Length);
173-
Assert.IsTrue(instances[0].IsPrimary);
175+
176+
if (instances.Length == 1)
177+
{
178+
Assert.IsTrue(instances[0].IsPrimary);
179+
}
180+
else
181+
{
182+
Assert.IsTrue(instances.Length > 1);
183+
Assert.AreEqual(1, instances.Count(i => i.IsPrimary));
184+
}
174185
}
175186

176187
[Test]
@@ -288,7 +299,7 @@ public void TestRequestStartSlaveOkNested()
288299
[Test]
289300
public void TestSecondaries()
290301
{
291-
Assert.AreEqual(0, _server.Secondaries.Length);
302+
Assert.IsTrue(_server.Secondaries.Length < _server.Instances.Length);
292303
}
293304

294305
[Test]

0 commit comments

Comments
 (0)