public void Test_Equals() { var a = new Color (1, 2, 3, 4); var b = new Color (1, 2, 3, 4); var c = new Color (1, 2, 3, 0); Assert.IsTrue (a.Equals (b)); Assert.IsTrue (a == b); Assert.AreEqual (a.GetHashCode (), b.GetHashCode ()); Assert.IsFalse (a.Equals (c)); Assert.IsFalse (a == c); Assert.AreNotEqual (a.GetHashCode (), c.GetHashCode ()); }
public void TestColorModel() { var c1 = new Color(); Assert.AreEqual(c1, default(Color)); Assert.IsTrue(c1 == default(Color)); Assert.IsFalse(c1 != default(Color)); Assert.IsTrue(((object)c1).Equals((object)default(Color))); Assert.AreEqual("00000000", c1.ToString()); var c2 = new Color(255, 0, 0, 0); Assert.AreEqual(c2.R, 255); Assert.AreEqual(c2.G, 0); Assert.AreEqual(c2.B, 0); Assert.AreEqual(c2.A, 0); Assert.AreEqual(Color.Red.ToString(), c2.ToString()); Assert.AreEqual(Color.Red.GetHashCode(), c2.GetHashCode()); }
private void WriteColor(string fieldName, Color value) { var bytes = BitConverter.GetBytes(value.GetHashCode()); var offset = Marshal.OffsetOf(typeof(DevDesc), fieldName).ToInt32(); Marshal.Copy(bytes, 0, IntPtr.Add(handle, offset), bytes.Length); }
public void TestHashCode () { var color1 = new Color (0.1); var color2 = new Color (0.1); Assert.True (color1.GetHashCode () == color2.GetHashCode ()); color2 = Color.FromHsla (color2.Hue, color2.Saturation, .5); Assert.False (color1.GetHashCode () == color2.GetHashCode ()); }