public void MessagesGethashCodeTest() { var msg1 = new FakeMsg("test", "testagain"); var msg2 = new FakeMsg("test", "testagain"); Assert.AreEqual(msg1.GetHashCode(), msg2.GetHashCode()); var msg3 = new FakeMsg("", ""); var msg4 = new FakeMsg("", ""); Assert.AreEqual(msg3.GetHashCode(), msg4.GetHashCode()); }
public void MessagesEqualsTest() { // Make sure that Equals will return false if the types are different Assert.IsFalse(TestMsgs[0].Equals(TestMsgs[1])); Assert.IsFalse(TestMsgs[0].Equals(true)); // Make sure that equals will return false if the content is different var msg1 = new FakeMsg("", ""); var msg2 = new FakeMsg("test", ""); Assert.IsFalse(msg1.Equals(msg2)); Assert.IsFalse(msg2.Equals(msg1)); // Make sure that equals will return true if the types and content are the same var msg3 = new FakeMsg("test", "testagain"); var msg4 = new FakeMsg("test", "testagain"); Assert.IsTrue(msg3.Equals(msg4)); Assert.IsTrue(msg4.Equals(msg3)); Assert.IsTrue(msg3.Equals((object)msg4)); Assert.IsTrue(msg4.Equals((object)msg3)); }
public void MessagesNotEqualsEqualsTest() { // Make sure that Equals will return false if the types are different Assert.IsTrue(TestMsgs[0] != TestMsgs[1]); Assert.IsTrue(TestMsgs[0] != true); // Make sure that equals will return false if the content is different var msg1 = new FakeMsg("", ""); var msg2 = new FakeMsg("test", ""); Assert.IsTrue(msg1 != msg2); Assert.IsTrue(msg2 != msg1); // Make sure that equals will return true if the types and content are the same var msg3 = new FakeMsg("test", "testagain"); var msg4 = new FakeMsg("test", "testagain"); Assert.IsFalse(msg3 != msg4); Assert.IsFalse(msg4 != msg3); Assert.IsFalse(msg3 != (object)msg4); Assert.IsFalse(msg4 != (object)msg3); }