private void defineExpectationsForCapacityOnCellChain() { context.checking( new Expectations() { { oneOf(cellChain).cellCount(); will(returnValue(capacity)); } }); }
private void defineExpectationsForOccupancyOnCellChain() { context.checking( new Expectations() { { oneOf(cellChain).occupancy(); will(returnValue(occupancy)); } }); }
@Test public void linkHasLength2() throws Exception { context.checking( new Expectations() { { oneOf(cellChain).cellCount(); will(returnValue(2)); } }); assertThat(link, NetworkMatchers.linkHasLength(2)); }
@Test public void linkContainsCellsCorrespondingToInJunctionFollowedByCellsInCellChainFollowedByOutJunction() throws Exception { context.checking( new Expectations() { { oneOf(cellChain).iterator(); will(returnIterator(linkCell0, linkCell1)); } }); assertThat(link.cells(), contains(inJunction, linkCell0, linkCell1, outJunction)); }
@Test public void getCellAtIndexReturnsDelgatesCallToCellChain() throws Exception { context.checking( new Expectations() { { oneOf(cellChain).getCellAtIndex(0); will(returnValue(linkCell0)); oneOf(cellChain).getCellAtIndex(1); will(returnValue(linkCell1)); } }); assertThat(link.getCell(0), is(linkCell0)); assertThat(link.getCell(1), is(linkCell1)); }
private LinkImpl linkWithConstructorExpectations() { context.checking( new Expectations() { { oneOf(cellChainBuilder).make(with(NetworkMatchers.linkNamed("myLink"))); will(returnValue(cellChain)); } }); return new LinkImpl( linkOccupancyFactory, occupancyFactory, "myLink", inJunction, cellChainBuilder, outJunction); }
@Test public void occupancyReturnsLinkOccupancyObject() throws Exception { defineExpectationsForOccupancyOnCellChain(); defineExpectationsForCapacityOnCellChain(); context.checking( new Expectations() { { oneOf(occupancyFactory).create(occupancy, capacity); will(returnValue(occupancyMeasure)); oneOf(linkOccupancyFactory).create(link, occupancyMeasure); will(returnValue(linkOccupancy)); } }); assertThat(link.occupancy(), is(linkOccupancy)); }