|
| 1 | +namespace MASA.BuildingBlocks.Configuration.Tests; |
| 2 | + |
| 3 | +[TestClass] |
| 4 | +public class TestProperties |
| 5 | +{ |
| 6 | + [TestMethod] |
| 7 | + public void TestEquals() |
| 8 | + { |
| 9 | + var id = Guid.NewGuid().ToString(); |
| 10 | + var x = new Properties(new Dictionary<string, string>() |
| 11 | + { |
| 12 | + {"id", id}, |
| 13 | + }); |
| 14 | + var y = new Properties(new Dictionary<string, string>() |
| 15 | + { |
| 16 | + {"id", id}, |
| 17 | + }); |
| 18 | + var z = new Properties(new Dictionary<string, string>() |
| 19 | + { |
| 20 | + {"id2", Guid.NewGuid().ToString()}, |
| 21 | + {"id", id} |
| 22 | + }); |
| 23 | + Assert.IsTrue(x.Equals(y)); |
| 24 | + Assert.IsTrue(!x.Equals(null)); |
| 25 | + Assert.IsTrue(!x.Equals(z)); |
| 26 | + Assert.IsTrue(!z.Equals(x)); |
| 27 | + |
| 28 | + var w = new Properties(new Dictionary<string, string>() |
| 29 | + { |
| 30 | + {"id", Guid.NewGuid().ToString()}, |
| 31 | + }); |
| 32 | + |
| 33 | + Assert.IsFalse(x!.Equals(w)); |
| 34 | + } |
| 35 | + |
| 36 | + [TestMethod] |
| 37 | + public void TestGetHashCode() |
| 38 | + { |
| 39 | + var id = Guid.NewGuid().ToString(); |
| 40 | + Properties x = new(new Dictionary<string, string>() { { "Id", id } }); |
| 41 | + Properties y = new(new Dictionary<string, string>() { { "Id", id } }); |
| 42 | + |
| 43 | + Assert.AreEqual(x.GetHashCode(), y.GetHashCode()); |
| 44 | + } |
| 45 | + |
| 46 | + [TestMethod] |
| 47 | + public void TestOperator() |
| 48 | + { |
| 49 | + var id = Guid.NewGuid().ToString(); |
| 50 | + Properties x = new(new Dictionary<string, string>() { { "Id", id } }); |
| 51 | + Properties y = new(new Dictionary<string, string>() { { "Id", id } }); |
| 52 | + Properties z = new(new Dictionary<string, string>() { { "Id", Guid.NewGuid().ToString() } }); |
| 53 | + |
| 54 | + Assert.IsTrue(x == y); |
| 55 | + Assert.IsTrue(x != z); |
| 56 | + |
| 57 | + Properties m = null; |
| 58 | + Assert.IsTrue(m == null); |
| 59 | + Assert.IsTrue(null == m); |
| 60 | + Assert.IsFalse(null != m); |
| 61 | + Assert.IsFalse(m != null); |
| 62 | + } |
| 63 | +} |
0 commit comments