public void after_add_channel_should_have_it_on_its_list() { var channel = MockRepository.GenerateStub<IChannel>(); var routingAlgorithm = MockRepository.GenerateStub<IRoutingAlgorithm>(); var switchingMatrix = new SwitchingMatrix(routingAlgorithm); switchingMatrix.AddChannel(channel); switchingMatrix.Channels.Should().Have.SameSequenceAs(new[] {channel}); }
public void should_ask_for_routing_algorithm_when_verifying_channels_availability() { var routingAlgorithm = MockRepository.GenerateMock<IRoutingAlgorithm>(); var switchingMatrix = new SwitchingMatrix(routingAlgorithm); switchingMatrix.AddChannel(MockRepository.GenerateStub<IChannel>()); routingAlgorithm.Expect(x => x.Route(switchingMatrix.Channels)) .Return(switchingMatrix.Channels.FirstOrDefault()); switchingMatrix.HasAvailableChannelFor(new Flit()); routingAlgorithm.VerifyAllExpectations(); }
public void should_not_have_channel_for_flit_when_buffers_full() { var returningChannel = MockRepository.GenerateMock<IChannel>(); var routingAlgorithm = MockRepository.GenerateStub<IRoutingAlgorithm>(); var flit = new Flit(); returningChannel.Expect(x => x.IsFull()).Return(true); returningChannel.Expect(x => x.IsReservedForOtherThan(flit)).Return(false); routingAlgorithm.Stub(x => x.Route(null)).IgnoreArguments().Return(returningChannel); var switchingMatrix = new SwitchingMatrix(routingAlgorithm); switchingMatrix.AddChannel(returningChannel); switchingMatrix.HasAvailableChannelFor(flit).IsAvailable.Should().Be.False(); }
public void should_reserve_channel_for_flit_when_the_head_pass_by() { var returningChannel = MockRepository.GenerateMock<IChannel>(); var routingAlgorithm = MockRepository.GenerateStub<IRoutingAlgorithm>(); var flit = new Flit { Type = FlitType.Header }; returningChannel.Stub(x => x.IsFull()).Return(false); returningChannel.Stub(x => x.IsReservedForOtherThan(flit)).Return(false); routingAlgorithm.Stub(x => x.Route(null)).IgnoreArguments().Return(returningChannel); var switchingMatrix = new SwitchingMatrix(routingAlgorithm); switchingMatrix.AddChannel(returningChannel); returningChannel.Expect(x => x.Reserve(flit)); switchingMatrix.HasAvailableChannelFor(flit).RouteIfAvailable(); returningChannel.VerifyAllExpectations(); }