public void SutDoesNotEqualAnonymousObject(object other)
        {
            var sut    = new MethodInfoElement(TypeWithMethods.Method);
            var actual = sut.Equals(other);

            Assert.False(actual);
        }
        public void ToElementForMethodInfoReturnsTheCorrectElement()
        {
            MethodInfo        expected = typeof(TypeWithAllElements).GetMethods()[0];
            MethodInfoElement actual   = expected.ToElement();

            Assert.Equal(new MethodInfoElement(expected), actual);
        }
 public void SutIsReflectionElement()
 {
     // Fixture setup
     // Exercise system
     var sut = new MethodInfoElement(TypeWithMethods.Method);
     // Verify outcome
     Assert.IsAssignableFrom<IReflectionElement>(sut);
     // Teardown
 }
        public void SutDoesNotEqualDifferentInstanceOfSameType()
        {
            var sut         = new MethodInfoElement(TypeWithMethods.Method);
            var otherMethod = this.GetType().GetMethods()[0];
            var other       = new MethodInfoElement(otherMethod);

            var actual = sut.Equals(other);

            Assert.False(actual);
        }
        public void SutIsReflectionElement()
        {
            // Fixture setup
            // Exercise system
            var sut = new MethodInfoElement(TypeWithMethods.Method);

            // Verify outcome
            Assert.IsAssignableFrom <IReflectionElement>(sut);
            // Teardown
        }
        public void SutEqualsOtherIdenticalInstance()
        {
            var mi    = TypeWithMethods.Method;
            var sut   = new MethodInfoElement(mi);
            var other = new MethodInfoElement(mi);

            var actual = sut.Equals(other);

            Assert.True(actual);
        }
        public void SutEqualsOtherIdenticalInstance()
        {
            var mi = TypeWithMethods.Method;
            var sut = new MethodInfoElement(mi);
            var other = new MethodInfoElement(mi);

            var actual = sut.Equals(other);

            Assert.True(actual);
        }
 public void AcceptNullVisitorThrows()
 {
     // Fixture setup
     var sut = new MethodInfoElement(TypeWithMethods.Method);
     // Exercise system
     // Verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.Accept((IReflectionVisitor<object>)null));
     // Teardown
 }
 public void MethodInfoIsCorrect()
 {
     // Fixture setup
     var expected = TypeWithMethods.Method;
     var sut = new MethodInfoElement(expected);
     // Exercise system
     MethodInfo actual = sut.MethodInfo;
     // Verify outcome
     Assert.Equal(expected, actual);
     // Teardown
 }
Beispiel #10
0
        public void GetHashCodeReturnsCorrectResult(Type t)
        {
            var mi  = t.GetMethod(nameof(GetHashCode));
            var sut = new MethodInfoElement(mi);

            var actual = sut.GetHashCode();

            var expected = mi.GetHashCode();

            Assert.Equal(expected, actual);
        }
Beispiel #11
0
        public void AcceptNullVisitorThrows()
        {
            // Fixture setup
            var sut = new MethodInfoElement(TypeWithMethods.Method);

            // Exercise system
            // Verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Accept((IReflectionVisitor <object>)null));
            // Teardown
        }
Beispiel #12
0
        public void VisitMethodInfoElementReturnsCorrectResult()
        {
            var sut = new ReflectionVisitor();
            var methodInfoElement =
                new MethodInfoElement(new Dummy().Method);

            var actual = sut.Visit(methodInfoElement);

            var expected = sut;

            Assert.Same(expected, actual);
        }
Beispiel #13
0
        public void MethodInfoIsCorrect()
        {
            // Fixture setup
            var expected = TypeWithMethods.Method;
            var sut      = new MethodInfoElement(expected);
            // Exercise system
            MethodInfo actual = sut.MethodInfo;

            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }
        public void AcceptCallsTheCorrectVisitorMethodAndReturnsTheCorrectInstance()
        {
            // Fixture setup
            var expected = new DelegatingReflectionVisitor<int>();
            var sut = new MethodInfoElement(TypeWithMethods.Method);
            var visitor = new DelegatingReflectionVisitor<int>
            {
                OnVisitMethodInfoElement = e =>
                    e == sut ? expected : new DelegatingReflectionVisitor<int>()
            };

            // Exercise system
            var actual = sut.Accept(visitor);
            // Verify outcome
            Assert.Same(expected, actual);
            // Teardown
        }
Beispiel #15
0
        public void AcceptCallsTheCorrectVisitorMethodAndReturnsTheCorrectInstance()
        {
            // Fixture setup
            var expected = new DelegatingReflectionVisitor <int>();
            var sut      = new MethodInfoElement(TypeWithMethods.Method);
            var visitor  = new DelegatingReflectionVisitor <int>
            {
                OnVisitMethodInfoElement = e =>
                                           e == sut ? expected : new DelegatingReflectionVisitor <int>()
            };

            // Exercise system
            var actual = sut.Accept(visitor);

            // Verify outcome
            Assert.Same(expected, actual);
            // Teardown
        }
 public void SutDoesNotEqualAnonymousObject(object other)
 {
     var sut = new MethodInfoElement(TypeWithMethods.Method);
     var actual = sut.Equals(other);
     Assert.False(actual);
 }
 public virtual IReflectionVisitor <T> Visit(MethodInfoElement methodInfoElement)
 {
     return(OnVisitMethodInfoElement(methodInfoElement));
 }
        public void GetHashCodeReturnsCorrectResult(Type t)
        {
            var mi = TypeWithMethods.Method;
            var sut = new MethodInfoElement(mi);

            var actual = sut.GetHashCode();

            var expected = mi.GetHashCode();
            Assert.Equal(expected, actual);
        }
        public void SutDoesNotEqualDifferentInstanceOfSameType()
        {
            var sut = new MethodInfoElement(TypeWithMethods.Method);
            var otherMethod = this.GetType().GetMethods()[0];
            var other = new MethodInfoElement(otherMethod);

            var actual = sut.Equals(other);

            Assert.False(actual);
        }