Esempio n. 1
0
        public void GetHashCode_ShouldCallInnerGetHashCode()
        {
            var comparer = new FuncEqualityComparer <object>((x, y) => true);
            var str      = Substitute.For <object>();

            comparer.GetHashCode(str);

            str.Received(1).GetHashCode();
        }
        public void GetHashCode_StrValueNull_ReturnsZero()
        {
            var comparer = new FuncEqualityComparer <ComparerTestObject, string>(x => x.StrValue);

            var testObj1 = new ComparerTestObject {
                StrValue = null
            };

            Assert.Equal(0, comparer.GetHashCode(testObj1));
        }
        public void GetHashCode_StrValue_ReturnsIntHashCode()
        {
            var comparer = new FuncEqualityComparer <ComparerTestObject, string>(x => x.StrValue);

            var testObj1 = new ComparerTestObject {
                StrValue = "HelloWorld"
            };

            Assert.Equal(testObj1.StrValue.GetHashCode(), comparer.GetHashCode(testObj1));
        }
        public void GetHashCode_IntValue_ReturnsIntHashCode()
        {
            var comparer = new FuncEqualityComparer <ComparerTestObject, int>(x => x.IntValue1);

            var testObj1 = new ComparerTestObject {
                IntValue1 = 1
            };

            Assert.Equal(testObj1.IntValue1.GetHashCode(), comparer.GetHashCode(testObj1));
        }