public void Subscribe_Generic_Validate()
        {
            // 1) arrange
            var listener = MockRepository.GenerateMock <IListener <Simple_MockEvent> >();

            // 2) act
            eventAggregator.Subscribe(listener);
            Dictionary <Type, List <IListener> > listeners = FieldReflector.GetListeners(eventAggregator);

            // 3) assert
            Assert.Contains(listener, listeners[typeof(Simple_MockEvent)]);
        }
        public void Unsubscribe_Validate()
        {
            // 1) arrange
            var listener = new Simple_MockListener();

            // 2) act
            eventAggregator.Subscribe(listener);
            eventAggregator.Unsubscribe(listener);
            Dictionary <Type, List <IListener> > listeners = FieldReflector.GetListeners(eventAggregator);

            // 3) assert
            Assert.DoesNotContain(listener, listeners[typeof(Simple_MockEvent)]);
        }
        public void Unsubscribe_Not_Contains_Listener()
        {
            // 1) arrange
            var listener = new Simple_MockListener();

            // 2) act
            eventAggregator.Unsubscribe(listener);

            // 3) assert
            Dictionary <Type, List <IListener> > listeners = FieldReflector.GetListeners(eventAggregator);

            Assert.DoesNotContain(typeof(Simple_MockEvent), listeners.Keys);
        }
        public void Subscribe_Listener_For_Two_Type_Events_Validate()
        {
            // 1) arrange
            var listener = new CallHandleCounter_ForTwoEvents_MockListener();

            // 2) act
            eventAggregator.Subscribe(listener);
            Dictionary <Type, List <IListener> > listeners = FieldReflector.GetListeners(eventAggregator);

            // 3) assert
            Assert.Contains(listener, listeners[typeof(Simple_MockEvent)]);
            Assert.Contains(listener, listeners[typeof(Another_MockEvent)]);
        }
        public void Unsubscribe_Not_Exists_Validate()
        {
            // 1) arrange
            var listener      = new Simple_MockListener();
            var twiceListener = new CallHandleCounter_ForTwoEvents_MockListener();

            // 2) act
            eventAggregator.Subscribe(listener);
            eventAggregator.Unsubscribe <Simple_MockEvent>(twiceListener);
            Dictionary <Type, List <IListener> > listeners = FieldReflector.GetListeners(eventAggregator);

            // 3) assert
            Assert.Contains(listener, listeners[typeof(Simple_MockEvent)]);
        }
        public void Subscribe_More_The_One_Validate()
        {
            // 1) arrange
            var listenerOne = MockRepository.GenerateMock <IListener <Simple_MockEvent> >();
            var listenerTwo = new Simple_MockListener();

            // 2) act
            eventAggregator.Subscribe(listenerOne);
            eventAggregator.Subscribe(listenerTwo);
            Dictionary <Type, List <IListener> > listeners = FieldReflector.GetListeners(eventAggregator);

            // 3) assert
            Assert.Contains(listenerOne, listeners[typeof(Simple_MockEvent)]);
            Assert.Contains(listenerTwo, listeners[typeof(Simple_MockEvent)]);
        }
        public void Subscribe_More_The_One_Another_Events_Validate()
        {
            // 1) arrange
            var listenerOne   = MockRepository.GenerateMock <IListener <Simple_MockEvent> >();
            var listenerTwo   = new Simple_MockListener();
            var listenerTwice = new CallHandleCounter_ForTwoEvents_MockListener();

            // 2) act
            eventAggregator.Subscribe(listenerOne);
            eventAggregator.Subscribe(listenerTwo);
            eventAggregator.Subscribe(listenerTwice);
            Dictionary <Type, List <IListener> > listeners = FieldReflector.GetListeners(eventAggregator);
            int expectedCountSimpleEventListeners          = 3;
            int expectedCountAnotherEventListeners         = 1;

            // 3) assert
            Assert.Equal(expectedCountSimpleEventListeners, listeners[typeof(Simple_MockEvent)].Count);
            Assert.Equal(expectedCountAnotherEventListeners, listeners[typeof(Another_MockEvent)].Count);
        }