Beispiel #1
0
        public void When_monitoring_a_class_it_should_be_possible_to_attach_to_additional_interfaces_on_the_same_object()
        {
            // Arrange
            var subject = new TestEventRaising();

            using var outerMonitor = subject.Monitor <IEventRaisingInterface>();
            using var innerMonitor = subject.Monitor <IEventRaisingInterface2>();

            // Act
            subject.RaiseBothEvents();

            // Assert
            outerMonitor.Should().Raise("InterfaceEvent");
            innerMonitor.Should().Raise("Interface2Event");
        }
        public void When_monitoring_a_class_it_should_be_possible_to_attach_to_additional_interfaces_on_the_same_object()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //----------------------------------------------------------------------------------------------------------
            var subject = new TestEventRaising();
            subject.MonitorEvents<IEventRaisingInterface>();
            subject.MonitorEvents<IEventRaisingInterface2>();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            subject.RaiseBothEvents();

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            subject.ShouldRaise("InterfaceEvent");
            subject.ShouldRaise("Interface2Event");
        }
        public void When_monitoring_more_than_one_event_on_a_class_it_should_be_possible_to_reset_just_one()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //----------------------------------------------------------------------------------------------------------
            var subject = new TestEventRaising();
            var eventRecorder = subject.MonitorEvents<IEventRaisingInterface>().GetEventRecorder("InterfaceEvent");
            subject.MonitorEvents<IEventRaisingInterface2>();
            subject.RaiseBothEvents();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            eventRecorder.Reset();

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            subject.ShouldNotRaise("InterfaceEvent");
            subject.ShouldRaise("Interface2Event");
        }