Beispiel #1
0
        public void SutDoesNotEqualAnonymousObject(object other)
        {
            var sut    = new EventInfoElement(TypeWithEvents.LocalEvent);
            var actual = sut.Equals(other);

            Assert.False(actual);
        }
        public void ToElementForEventInfoReturnsTheCorrectElement()
        {
            EventInfo        expected = typeof(TypeWithAllElements).GetEvents().Single();
            EventInfoElement actual   = expected.ToElement();

            Assert.Equal(new EventInfoElement(expected), actual);
        }
Beispiel #3
0
        public void SutEqualsOtherIdenticalInstance()
        {
            var ei    = TypeWithEvents.LocalEvent;
            var sut   = new EventInfoElement(ei);
            var other = new EventInfoElement(ei);

            var actual = sut.Equals(other);

            Assert.True(actual);
        }
Beispiel #4
0
        public void SutDoesNotEqualDifferentInstanceOfSameType()
        {
            var sut        = new EventInfoElement(TypeWithEvents.LocalEvent);
            var otherEvent = typeof(Assembly).GetEvent("ModuleResolve");
            var other      = new EventInfoElement(otherEvent);

            var actual = sut.Equals(other);

            Assert.False(actual);
        }
        public void GetHashCodeReturnsCorrectResult()
        {
            var ei = TypeWithEvent.LocalEvent;
            var sut = new EventInfoElement(ei);

            var actual = sut.GetHashCode();

            var expected = ei.GetHashCode();
            Assert.Equal(expected, actual);
        }
Beispiel #6
0
        public void SutIsReflectionElement()
        {
            // Fixture setup
            // Exercise system
            var sut = new EventInfoElement(TypeWithEvents.LocalEvent);

            // Verify outcome
            Assert.IsAssignableFrom <IReflectionElement>(sut);
            // Teardown
        }
 public void AcceptNullVisitorThrows()
 {
     // Fixture setup
     var sut = new EventInfoElement(TypeWithEvent.LocalEvent);
     // Exercise system
     // Verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.Accept((IReflectionVisitor<object>)null));
     // Teardown
 }
Beispiel #8
0
        public void AcceptNullVisitorThrows()
        {
            // Fixture setup
            var sut = new EventInfoElement(TypeWithEvents.LocalEvent);

            // Exercise system
            // Verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Accept((IReflectionVisitor <object>)null));
            // Teardown
        }
Beispiel #9
0
        public void GetHashCodeReturnsCorrectResult()
        {
            var ei  = TypeWithEvents.LocalEvent;
            var sut = new EventInfoElement(ei);

            var actual = sut.GetHashCode();

            var expected = ei.GetHashCode();

            Assert.Equal(expected, actual);
        }
 public void EventInfoIsCorrect()
 {
     // Fixture setup
     var expected = TypeWithEvent.LocalEvent;
     var sut = new EventInfoElement(expected);
     // Exercise system
     EventInfo actual = sut.EventInfo;
     // Verify outcome
     Assert.Equal(expected, actual);
     // Teardown
 }
Beispiel #11
0
        public void EventInfoIsCorrect()
        {
            // Fixture setup
            var expected = TypeWithEvents.LocalEvent;
            var sut      = new EventInfoElement(expected);
            // Exercise system
            EventInfo actual = sut.EventInfo;

            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }
Beispiel #12
0
        public void VisitEventInfoElementReturnsCorrectResult()
        {
            var sut = new ReflectionVisitor();
            var eventInfoElement =
                new EventInfoElement(new Dummy().Event);

            var actual = sut.Visit(eventInfoElement);

            var expected = sut;

            Assert.Same(expected, actual);
        }
        public void AcceptCallsTheCorrectVisitorMethodAndReturnsTheCorrectInstance()
        {
            // Fixture setup
            var expected = new DelegatingReflectionVisitor<int>();
            var sut = new EventInfoElement(TypeWithEvent.LocalEvent);
            var visitor = new DelegatingReflectionVisitor<int>
            {
                OnVisitEventInfoElement = e =>
                    e == sut ? expected : new DelegatingReflectionVisitor<int>()
            };

            // Exercise system
            var actual = sut.Accept(visitor);
            // Verify outcome
            Assert.Same(expected, actual);
            // Teardown
        }
Beispiel #14
0
        public void AcceptCallsTheCorrectVisitorMethodAndReturnsTheCorrectInstance()
        {
            // Fixture setup
            var expected = new DelegatingReflectionVisitor <int>();
            var sut      = new EventInfoElement(TypeWithEvents.LocalEvent);
            var visitor  = new DelegatingReflectionVisitor <int>
            {
                OnVisitEventInfoElement = e =>
                                          e == sut ? expected : new DelegatingReflectionVisitor <int>()
            };

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

            // Verify outcome
            Assert.Same(expected, actual);
            // Teardown
        }
 public void SutIsReflectionElement()
 {
     // Fixture setup
     // Exercise system
     var sut = new EventInfoElement(TypeWithEvent.LocalEvent);
     // Verify outcome
     Assert.IsAssignableFrom<IReflectionElement>(sut);
     // Teardown
 }
        public void SutDoesNotEqualDifferentInstanceOfSameType()
        {
            var sut = new EventInfoElement(TypeWithEvent.LocalEvent);
            var otherEvent = typeof(Assembly).GetEvent("ModuleResolve");
            var other = new EventInfoElement(otherEvent);

            var actual = sut.Equals(other);

            Assert.False(actual);
        }
 public void SutDoesNotEqualAnonymousObject(object other)
 {
     var sut = new EventInfoElement(TypeWithEvent.LocalEvent);
     var actual = sut.Equals(other);
     Assert.False(actual);
 }
 public virtual IReflectionVisitor <T> Visit(EventInfoElement eventInfoElement)
 {
     return(OnVisitEventInfoElement(eventInfoElement));
 }
        public void SutEqualsOtherIdenticalInstance()
        {
            var ei = TypeWithEvent.LocalEvent;
            var sut = new EventInfoElement(ei);
            var other = new EventInfoElement(ei);

            var actual = sut.Equals(other);

            Assert.True(actual);
        }