// Javadoc inherited from superclass
public void setUp() throws Exception {
super.setUp();
indexMock = new NDimensionalIndexMock(
"indexMock", expectations, new int[0]);
// Create a sequence of indeces.
childMockIndeces = new NDimensionalIndexMock[10];
NDimensionalIndexMock next = null;
for (int i = childMockIndeces.length - 1; i >= 0; i--) {
NDimensionalIndexMock childMockIndex = new NDimensionalIndexMock(
"childIndexMock" + i, expectations, new int[0]);
childMockIndeces[i] = childMockIndex;
// If this is not the last in the list then make sure that
// incrementing this index by 1 returns the next one.
if (next != null) {
childMockIndex.expects.incrementCurrentFormatIndex(1)
.returns(next).any();
}
// Remember this for next time around.
next = childMockIndex;
}
// Iterate over and make sure that they can all be set to another.
for (int i = 0; i < childMockIndeces.length; i++) {
NDimensionalIndexMock index1 = childMockIndeces[i];
for (int j = i; j < childMockIndeces.length; j++) {
NDimensionalIndexMock index2 = childMockIndeces[j];
index1.expects.setCurrentFormatIndex(j)
.returns(index2).any();
index2.expects.setCurrentFormatIndex(i)
.returns(index1).any();
}
}
childInstanceMock = new FormatInstanceMock(
"childInstanceMock", expectations,
NDimensionalIndex.ZERO_DIMENSIONS);
childMock = LayoutTestHelper.createFormatMock(
"childMock", expectations, canvasLayoutMock);
// Create an association between the child instance and its format.
for (int i = 0; i < childMockIndeces.length; i++) {
NDimensionalIndexMock childMockIndex = childMockIndeces[i];
FormatRendererTestHelper.connectFormatInstanceToFormat(
formatRendererContextMock,
childInstanceMock.expects, childMock, childMockIndex);
}