/**
* Test method for {@link flyingdiamond.model.chainreaction.ActivateSameDiamondChainReaction#react(int, int, flyingdiamond.model.ArticleMatrix)}.
*/
@Test
public void testReact() {
Article blueDia = ArticleFactory.getInstance().createArticle(ArticleEnum.BLUE_DIAMOND);
Article greenDia = ArticleFactory.getInstance().createArticle(ArticleEnum.GREEN_DIAMOND);
//Set pattern to different positions,check whether the react method work well.
for (int i = 0; i < ArticleMatrix.HEIGHT; i++) {
for (int j = 0; j < ArticleMatrix.WIDTH; j++) {
ArticleMatrix matrix = generateTestMatrix(i,j);
int nullCells = reaction.react(i, j, matrix);
int redDiamonds = 0;
for (int row = 0; row < ArticleMatrix.HEIGHT; row++) {
for (int col = 0; col < ArticleMatrix.WIDTH; col++) {
Article art = matrix.getArticle(row, col);
if (art.equals(greenDia) && !art.isActivated()) {
redDiamonds++;
}
}
}
assertEquals(nullCells+redDiamonds,ArticleMatrix.HEIGHT*ArticleMatrix.WIDTH );