Example #1
0
        public void Should_use_scheduler_for_incoming_messages()
        {
            var message = MockRepository.GenerateMock <IMessage>();

            Channel.Raise(c => c.Received += null, message);
            Scheduler.AssertWasCalled(s => s.Execute(Arg <Action> .Is.Anything));
        }
Example #2
0
        public void Should_fire_connection_opened_in_nonblocking_way()
        {
            var wasEventFired = false;

            _subject.ConnectionOpened += c => wasEventFired = true;

            //opening channel will effect with calling task scheduler, but event will be not raised because mock scheduler is not stubbed
            OpenChannel();
            _taskScheduler.AssertWasCalled(s => s.Execute(Arg <Action> .Is.Anything));
            Assert.That(wasEventFired, Is.False);

            //after scheduler is stubbed, opening channel will effect with raising an event
            _taskScheduler.Stub(s => s.Execute(Arg <Action> .Is.Anything)).WhenCalled(m => ((Action)m.Arguments[0]).Invoke());
            OpenChannel();
            Assert.That(wasEventFired, Is.True);
        }