public void Equals_EdgeTest() { StackInt si = new StackInt(100); object sObj = "StackInt!"; object nl = null; Assert.False(si.Equals(sObj)); Assert.False(si.Equals(nl)); }
public void Comparison_EqualTest() { StackInt first = new StackInt(1); StackInt second = new StackInt(1); Assert.False(first > second); Assert.True(first >= second); Assert.False(second < first); Assert.True(second <= first); Assert.True(first == second); Assert.False(first != second); Assert.Equal(0, first.CompareTo(second)); Assert.Equal(0, first.CompareTo((object)second)); Assert.True(first.Equals(second)); Assert.True(first.Equals((object)second)); }
public void ComparisonOperator_SameTypeTest(StackInt si1, StackInt si2, ValueCompareResult expected) { Assert.Equal(expected.Bigger, si1 > si2); Assert.Equal(expected.BiggerEqual, si1 >= si2); Assert.Equal(expected.Smaller, si1 < si2); Assert.Equal(expected.SmallerEqual, si1 <= si2); Assert.Equal(expected.Equal, si1 == si2); Assert.Equal(!expected.Equal, si1 != si2); Assert.Equal(expected.Equal, si1.Equals(si2)); Assert.Equal(expected.Equal, si1.Equals((object)si2)); Assert.Equal(expected.Compare, si1.CompareTo(si2)); Assert.Equal(expected.Compare, si1.CompareTo((object)si2)); }
public void ComparisonTest() { StackInt big = new StackInt(1); StackInt small = new StackInt(0); Assert.True(big > small); Assert.True(big >= small); Assert.True(small < big); Assert.True(small <= big); Assert.False(big == small); Assert.True(big != small); Assert.Equal(1, big.CompareTo(small)); Assert.Equal(1, big.CompareTo((object)small)); Assert.Equal(-1, small.CompareTo(big)); Assert.Equal(-1, small.CompareTo((object)big)); Assert.False(big.Equals(small)); Assert.False(big.Equals((object)small)); }