public void TestEquals() { var rand = new Random(); var a = new DiceRoll( d4: (uint)rand.Next(), d6: (uint)rand.Next(), d8: (uint)rand.Next(), d10: (uint)rand.Next(), d12: (uint)rand.Next(), modifier: rand.Next()); var b = new DiceRoll( d4: a.D4, d6: a.D6, d8: a.D8, d10: a.D10, d12: a.D12, modifier: a.Modifier); var c = new DiceRoll( d4: (uint)rand.Next(), d6: (uint)rand.Next(), d8: (uint)rand.Next(), d10: (uint)rand.Next(), d12: (uint)rand.Next(), modifier: rand.Next()); // Strongly typed version Assert.That(a.Equals(a), Is.True); Assert.That(a.Equals(b), Is.True); Assert.That(b.Equals(a), Is.True); Assert.That(a.Equals(c), Is.False); Assert.That(c.Equals(a), Is.False); Assert.That(a.Equals(null), Is.False); // Object version Assert.That(((object)a).Equals(a), Is.True); Assert.That(((object)a).Equals(b), Is.True); Assert.That(((object)b).Equals(a), Is.True); Assert.That(((object)a).Equals(c), Is.False); Assert.That(((object)c).Equals(a), Is.False); Assert.That(((object)a).Equals(null), Is.False); }