public void CanCompareColors() { var c1 = new Rgb(100, 100, 100); var c2 = new Rgb(100, 100, 100); Assert.IsTrue(c1 == c2); Assert.IsFalse(c1 != c2); Assert.AreEqual(c1.GetHashCode(), c2.GetHashCode()); Assert.IsTrue(c1.Equals(c2)); }
public void TestEquality() { Rgb a = new Rgb(1, 2, 3); Rgb b = new Rgb(1, 2, 3); Rgb c = new Rgb(1, 2, 2); Rgb d = new Rgb(1, 1, 3); Rgb e = new Rgb(2, 2, 3); Assert.Equal(true, a == b); Assert.Equal(true, a.Equals(b)); Assert.Equal(true, a != c); Assert.Equal(false, a == c); Assert.Equal(false, a.Equals(c)); Assert.Equal(false, a != b); Assert.Equal(false, a.Equals(null)); Assert.Equal(false, a == d); Assert.Equal(false, a == e); Assert.Equal(false, a.Equals(d)); Assert.Equal(false, a.Equals(e)); }
protected bool Equals(Color other) { return(Rgb.Equals(other.Rgb) && Alpha.Equals(other.Alpha)); }