public void Should_have_eventlistener()
        {
            // Arrange
            Action<ISecurityEvent> eventListener = @event => {};

            // Act
            var listener = new AnonymousSecurityEventListener(eventListener);

            // Assert
            Assert.That(listener.EventListener, Is.EqualTo(eventListener));
        }
        public void Should_not_throw_if_event_listener_throws()
        {
            // Arrange
            var @event = new ConfigurationEvent(Guid.NewGuid(), "Message");
            Action<ISecurityEvent> eventListener = e =>
            {
                throw new Exception("Exception message");
            };
            var listener = new AnonymousSecurityEventListener(eventListener);

            // Act & assert
            Assert.DoesNotThrow(() => listener.Handle(@event));
        }
Пример #3
0
        public void Should_register_multiple_event_listener()
        {
            // Arrange
            var doctor = new SecurityDoctor();
            ISecurityEventListener eventListener1 = new TestSecurityEventListener();
            ISecurityEventListener eventListener2 = new AnonymousSecurityEventListener(e => { });

            // Act
            doctor.RegisterListener(eventListener1);
            doctor.RegisterListener(eventListener2);

            // Assert
            Assert.That(doctor.Listeners.Count(), Is.EqualTo(2));
            Assert.That(doctor.Listeners.First(), Is.EqualTo(eventListener1));
            Assert.That(doctor.Listeners.Last(), Is.EqualTo(eventListener2));
        }