예제 #1
0
        public void should_verify_if_channels_are_available_when_receiving_flit()
        {
            var switchingMatrix = MockRepository.GenerateMock<ISwitchingMatrix>();
            var router = new Router(switchingMatrix);
            distributor.AddListener(router);
            var flit = new Flit();

            switchingMatrix.Expect(x => x.HasAvailableChannelFor(flit))
                .Return(new RoutingAvailabilityExpression(true));

            distributor.SendMessage(new FlitEvent { ClockCycle = 1, Flit = flit, CurrentReceiver = router });
            distributor.Distribute(1);

            switchingMatrix.VerifyAllExpectations();
        }
예제 #2
0
        public void should_decline_flit_when_no_channel_available()
        {
            var switchingMatrix = MockRepository.GenerateStub<ISwitchingMatrix>();
            var flitDeclinedReceiver = MockRepository.GenerateMock<IListenTo<FlitDeclinedEvent>.All>();
            distributor.AddListener(flitDeclinedReceiver);

            var router = new Router(switchingMatrix);
            distributor.AddListener(router);

            switchingMatrix.Stub(x => x.HasAvailableChannelFor(null)).IgnoreArguments()
                .Return(new RoutingAvailabilityExpression(false));

            flitDeclinedReceiver.Expect(x => x.Handle(null)).IgnoreArguments();

            distributor.SendMessage(new FlitEvent {ClockCycle = 1, Flit = new Flit(), CurrentReceiver = router});
            distributor.Distribute(1, 2);

            flitDeclinedReceiver.VerifyAllExpectations();
        }