Exemplo n.º 1
0
        public void NotEqualsDifferentInstance()
        {
            var method   = typeof(Foo).GetMethod(nameof(object.Equals));
            var behavior = new DefaultEqualityBehavior();
            var target   = new Foo();

            var actual = (bool)behavior.Execute(new MethodInvocation(target, method, new object[] { new Foo() }), () => null).ReturnValue;

            Assert.False(actual);
        }
Exemplo n.º 2
0
        public void NotEqualsDifferentInstance()
        {
            var method   = typeof(Foo).GetMethod(nameof(object.Equals)) !;
            var behavior = new DefaultEqualityBehavior();
            var target   = new Foo();

            var actual = (bool?)behavior.Execute(MethodInvocation.Create(target, method, new Foo()), null !).ReturnValue;

            Assert.False(actual);
        }
Exemplo n.º 3
0
        public void GetsHashCode()
        {
            var method   = typeof(Foo).GetMethod(nameof(object.GetHashCode));
            var behavior = new DefaultEqualityBehavior();
            var target   = new Foo();

            var expected = target.GetHashCode();
            var actual   = (int)behavior.Execute(new MethodInvocation(target, method, new object[0]), () => null).ReturnValue;

            Assert.Equal(expected, actual);
        }
Exemplo n.º 4
0
        public void InvokeNextIfNotEqualsOrGetHashCode()
        {
            var method     = typeof(Foo).GetMethod(nameof(Foo.ToString));
            var behavior   = new DefaultEqualityBehavior();
            var target     = new Foo();
            var nextCalled = false;

            behavior.Execute(
                new MethodInvocation(target, method),
                () => (m, n) =>
            {
                nextCalled = true;
                return(m.CreateValueReturn(null));
            });

            Assert.True(nextCalled);
        }