Пример #1
0
        public void Equals_ShouldCallFunc(int a, int b)
        {
            var func     = Substitute.For <Func <int, int, bool> >();
            var comparer = new FuncEqualityComparer <int>(func);

            comparer.Equals(a, b);

            func.Received(1).Invoke(a, b);
        }
        public void Equals_ReferenceOtherNull_ReturnsFalse()
        {
            var comparer = new FuncEqualityComparer <ComparerTestObject, string>(x => x.StrValue);

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

            Assert.False(comparer.Equals(testObj1, null));
        }
        public void Equals_SameReference_ReturnsTrue()
        {
            var comparer = new FuncEqualityComparer <ComparerTestObject, string>(x => x.StrValue);

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

            Assert.True(comparer.Equals(testObj, testObj));
        }
        public void Equals_NotEqual_ReturnsFalse()
        {
            var comparer = new FuncEqualityComparer <ComparerTestObject, int>(x => x.IntValue1);

            var testObj1 = new ComparerTestObject {
                IntValue1 = 1
            };
            var testObj2 = new ComparerTestObject {
                IntValue1 = 2
            };

            Assert.False(comparer.Equals(testObj1, testObj2));
        }