public void ThrowEventOfTypeWithSender()
        {
            var objectListening = new FakeObject();
            var objectActing    = new FakeObject {
                Name = "Actor"
            };
            var resultArgs = new RealmEventArgs();

            var handler = new EventHandler(new CommonTimer(), _mockLogger);

            _eventCallback = args => { resultArgs = args; };

            handler.RegisterListener(new EventListener(objectListening, null, typeof(FakeEvent), _eventCallback));

            handler.ThrowEvent <FakeEvent>(objectActing);

            Thread.Sleep(250);

            resultArgs.Sender.Should().NotBeNull();
            resultArgs.Sender.Should().BeAssignableTo <FakeObject>();

            var sender = resultArgs.Sender as FakeObject;

            sender.Name.Should().Be("Actor");
        }
        public void RegisterListenerToType()
        {
            var objectListening = new FakeObject();

            var handler = new EventHandler(new CommonTimer(), _mockLogger);

            handler.RegisterListener(new EventListener(objectListening, null, typeof(FakeEvent), _eventCallback));
        }
        public void RegisterListenerTwoObjectsToObjectToType()
        {
            var objectListener1 = new FakeObject();
            var objectListener2 = new FakeObject();
            var objectActing    = new FakeObject();

            var handler = new EventHandler(new CommonTimer(), _mockLogger);

            handler.RegisterListener(new EventListener(objectListener1, objectActing, typeof(FakeEvent), _eventCallback));
            handler.RegisterListener(new EventListener(objectListener2, objectActing, typeof(FakeEvent), _eventCallback));
        }
        public void IsListeningToType()
        {
            var objectListening = new FakeObject();

            var handler = new EventHandler(new CommonTimer(), _mockLogger);

            handler.RegisterListener(new EventListener(objectListening, null, typeof(FakeEvent), _eventCallback));

            var result = handler.IsListening(objectListening, typeof(FakeEvent));

            result.Should().BeTrue();
        }
        public void ThrowEvent_ThrowsException_WhenUnknownEventTypeIsPassed()
        {
            var objectListening = new FakeObject();
            var objectActing    = new FakeObject {
                Name = "Actor"
            };

            var handler = new EventHandler(new CommonTimer(), _mockLogger);

            handler.RegisterListener(new EventListener(objectListening, null, typeof(FakeEvent), _eventCallback));

            Action act = () => handler.ThrowEvent <BuggyFakeEvent>(objectActing);

            act.Should().Throw <InstanceNotFoundException>();
        }