Example #1
0
        public int DerivedClassMatchHandled(int iterations)
        {
            var hub     = new EventHub();
            var handler = new SyncBaseCountingHandler();

            hub.Register(handler);

            for (var i = 0; i < iterations; i++)
            {
                hub.AddEvent(new DerivedEvent());
                hub.AddEvent(42); //Should not handle this
            }

            return(handler.HandleCount);
        }
Example #2
0
        public int CatchAllHandled(int iterations)
        {
            var hub     = new EventHub();
            var handler = new SyncAllCountingHandler();

            hub.Register(handler);

            for (var i = 0; i < iterations; i++)
            {
                hub.AddEvent(new BaseEvent());
                hub.AddEvent(new DerivedEvent());
                hub.AddEvent(42);
            }

            return(handler.HandleCount);
        }
        public int?ExceptionIsAggregated(int instances)
        {
            var hub = new EventHub();

            for (var i = 0; i < instances; i++)
            {
                var handler = new SyncThrowsExceptionHandler();
                hub.Register(handler);
            }

            try
            {
                hub.AddEvent(new BaseEvent());
            }
            catch (AggregateException e)
            {
                return(e.InnerExceptions.Count);
            }

            return(null);
        }