Last active
November 1, 2020 16:04
-
-
Save joao-r-reis/608630f22a40cd8f08a6105e7a1b1762 to your computer and use it in GitHub Desktop.
BetterTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void Should_ReturnEqualsTrueAndSameHashCode_When_BothStrategiesHaveSameReplicationSettings() | |
{ | |
var target1 = new NetworkTopologyStrategy( | |
new Dictionary<string, int> | |
{ | |
{ "dc1", 2 }, | |
{ "dc2", 3 }, | |
{ "dc3", 1 } | |
}); | |
var target2 = new NetworkTopologyStrategy( | |
new Dictionary<string, int> | |
{ | |
{ "dc3", 1 }, | |
{ "dc1", 2 }, | |
{ "dc2", 3 } | |
}); | |
Assert.AreEqual(target1.GetHashCode(), target2.GetHashCode()); | |
Assert.IsTrue(target1.Equals(target2)); | |
Assert.IsTrue(target2.Equals(target1)); | |
Assert.AreEqual(target1, target2); | |
} | |
[Test] | |
public void Should_NotReturnEqualsTrue_When_StrategiesHaveDifferentReplicationFactors() | |
{ | |
var target1 = new NetworkTopologyStrategy( | |
new Dictionary<string, int> | |
{ | |
{ "dc1", 2 }, | |
{ "dc2", 1 }, | |
{ "dc3", 3 } | |
}); | |
var target2 = new NetworkTopologyStrategy( | |
new Dictionary<string, int> | |
{ | |
{ "dc3", 3 }, | |
{ "dc1", 2 }, | |
{ "dc2", 2 } | |
}); | |
Assert.AreNotEqual(target1.GetHashCode(), target2.GetHashCode()); | |
Assert.IsFalse(target1.Equals(target2)); | |
Assert.IsFalse(target2.Equals(target1)); | |
Assert.AreNotEqual(target1, target2); | |
} | |
[Test] | |
public void Should_NotReturnEqualsTrue_When_StrategiesHaveDifferentDatacenters() | |
{ | |
var target1 = new NetworkTopologyStrategy( | |
new Dictionary<string, int> | |
{ | |
{ "dc1", 2 }, | |
{ "dc2", 3 }, | |
}); | |
var target2 = new NetworkTopologyStrategy( | |
new Dictionary<string, int> | |
{ | |
{ "dc1", 2 }, | |
}); | |
Assert.AreNotEqual(target1.GetHashCode(), target2.GetHashCode()); | |
Assert.IsFalse(target1.Equals(target2)); | |
Assert.IsFalse(target2.Equals(target1)); | |
Assert.AreNotEqual(target1, target2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment