Ejemplo n.º 1
0
        public EventPublishingTests()
        {
            _eventList = new List <SimpleTextEvent>();
            _simpleTextEventHandler = new SimpleTextEventHandler(_eventList);

            _easyEvents = new EasyEvents();

            _easyEvents.Configure(new EasyEventsConfiguration
            {
                HandlerFactory = type =>
                {
                    return((type == typeof(IEventHandler <SimpleTextEvent>))
                    ? _simpleTextEventHandler
                    : null);
                },
                Store = new InMemoryEventStore()
            });

            DateAbstraction.Pause();

            // while (!System.Diagnostics.Debugger.IsAttached)
            //{
            //    System.Threading.Tasks.Task.Delay(100);
            //}
        }
Ejemplo n.º 2
0
        public async Task Throws_If_HandlerFactory_Returns_Type_That_Does_Not_Implement_Handler_Interface()
        {
            // Given
            _easyEvents.Configure(new EasyEventsConfiguration
            {
                HandlerFactory = type => new object(),
                Store          = new InMemoryEventStore()
            });

            // When
            var ex =
                await Record.ExceptionAsync(() => _easyEvents.RaiseEventAsync(new SimpleTextEvent("this should explode")));

            // Then
            ex.ShouldNotBeNull();
            ex.ShouldBeOfType <EventHandlerException>();
            ex.Message.ShouldBe(
                $"Cannot handle {nameof(SimpleTextEvent)}. Handler returned from Factory does not implement {nameof(IEventHandler<IEvent>)}<{nameof(SimpleTextEvent)}>");
        }