public void Equality() { var a = new TopicPartitionOffsetError("a", 31, 55, ErrorCode.NoError); var a2 = new TopicPartitionOffsetError("a", 31, 55, ErrorCode.NoError); var nes = new List <TopicPartitionOffsetError> { new TopicPartitionOffsetError("b", 31, 55, ErrorCode.NoError), new TopicPartitionOffsetError("a", 32, 55, ErrorCode.NoError), new TopicPartitionOffsetError("a", 31, 56, ErrorCode.NoError), new TopicPartitionOffsetError("a", 31, 55, ErrorCode.Local_Conflict), }; Assert.Equal(a, a2); Assert.True(a.Equals(a2)); Assert.True(a == a2); Assert.False(a != a2); foreach (var ne in nes) { Assert.NotEqual(a, ne); Assert.False(a.Equals(ne)); Assert.False(a == ne); Assert.True(a != ne); } }
public void NullEquality() { var tpoe1 = new TopicPartitionOffsetError("a", 31, 55, ErrorCode.NoError); TopicPartitionOffsetError tpoe2 = null; TopicPartitionOffsetError tpoe3 = null; Assert.NotEqual(tpoe1, tpoe2); Assert.False(tpoe1.Equals(tpoe2)); Assert.False(tpoe1 == tpoe2); Assert.True(tpoe1 != tpoe2); Assert.NotEqual(tpoe2, tpoe1); Assert.False(tpoe2 == tpoe1); Assert.True(tpoe2 != tpoe1); Assert.Equal(tpoe2, tpoe3); Assert.True(tpoe2 == tpoe3); Assert.False(tpoe2 != tpoe3); }