Example #1
0
        public void WhenCreatingPatternForBaseArgsType_ThenSucceeds()
        {
            var pattern = EventPattern.Create <EventArgs>(this, new FooArgs());

            Assert.NotNull(pattern);
            Assert.True(pattern.EventArgs is FooArgs);
        }
 public bool Equals(EventPattern <TEventArgs> other)
 {
     if ((object)other == null)
     {
         return(false);
     }
     return(((object)sender == null ? (object)other.sender == null : sender.Equals(other.sender)) && e.Equals(other.e));
 }
Example #3
0
        public void WhenPushingEventPattern_ThenCanSubscribeToEventArgsOnlyToo()
        {
            var stream = new EventStream();
            var called = false;

            using (var subscription = stream.Of <BaseEvent>().Subscribe(c => called = true))
            {
                stream.Push(EventPattern.Create(this, new PatientEnteredHospital()));
            }

            Assert.True(called);
        }
Example #4
0
        public void WhenSubscribingAsGenericInterfaceConcreteArgs_ThenCallsSubscriber()
        {
            var stream = new EventStream();
            var called = false;

            using (var subscription = stream.Of <IEventPattern <PatientEnteredHospital> >().Subscribe(c => called = true))
            {
                stream.Push(EventPattern.Create(this, new PatientEnteredHospital()));
            }

            Assert.True(called);
        }
Example #5
0
        protected override EventPattern <TTarget> Convert(EventPattern <TSource> value)
        {
            Contract.Assume(value != null);

            return(new EventPattern <TTarget>(value.Sender, (TTarget)(object)value.EventArgs));
        }
Example #6
0
        public void WhenCreatingPatternForSameArgsType_ThenSucceeds()
        {
            var pattern = EventPattern.Create <EventArgs>(this, EventArgs.Empty);

            Assert.NotNull(pattern);
        }
Example #7
0
 public void WhenCreatingPatternForNullEventArgs_ThenThrows()
 {
     Assert.Throws <ArgumentNullException>(() => EventPattern.Create <EventArgs>(this, null));
 }
Example #8
0
 public void WhenCreatingPatternForNullSender_ThenThrows()
 {
     Assert.Throws <ArgumentNullException>(() => EventPattern.Create(null, EventArgs.Empty));
 }
Example #9
0
 protected override void OnNextCore(EventPattern <TSender, TEventArgs> value)
 {
     _sourceBase._invokeHandler(_invoke, value);
 }
Example #10
0
 public bool Equals(EventPattern <TSender, TEventArgs> other)