-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
104 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/test/java/com/samabcde/puzzlesolver/solve/SolutionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.samabcde.puzzlesolver.solve; | ||
|
||
import com.samabcde.puzzlesolver.component.Block; | ||
import com.samabcde.puzzlesolver.component.BlockPosition; | ||
import com.samabcde.puzzlesolver.component.BlockPuzzle; | ||
import com.samabcde.puzzlesolver.component.Dimension; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class SolutionTest { | ||
@Nested | ||
public class Given_EmptySolution { | ||
BlockPuzzle blockPuzzle = new BlockPuzzle(new Dimension(1, 1), new String[]{"1"}); | ||
Solution solution = new Solution(blockPuzzle); | ||
|
||
@Test | ||
public void itSizeIs0() { | ||
assertEquals(0, solution.size()); | ||
} | ||
|
||
@Test | ||
public void itIsEmpty() { | ||
assertTrue(solution.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void itDoesNotContainsBlock() { | ||
blockPuzzle.getBlocks().forEach(block -> | ||
assertFalse(solution.containsBlock(block))); | ||
} | ||
|
||
@Test | ||
public void pollThrowException() { | ||
assertThrows(NoSuchElementException.class, () -> solution.poll()); | ||
} | ||
} | ||
|
||
@Nested | ||
public class AddOnePosition { | ||
BlockPuzzle blockPuzzle = new BlockPuzzle(new Dimension(1, 1), new String[]{"1"}); | ||
Solution solution = new Solution(blockPuzzle); | ||
Block block = blockPuzzle.getBlocks().getFirst(); | ||
BlockPosition blockPosition = block.getBlockPositions().getFirst(); | ||
|
||
@BeforeEach | ||
public void setup() { | ||
solution.push(blockPuzzle.getBlocks().getFirst().getBlockPositions().getFirst()); | ||
} | ||
|
||
@Test | ||
public void itSizeIs1() { | ||
assertEquals(1, solution.size()); | ||
} | ||
|
||
@Test | ||
public void itIsNotEmpty() { | ||
assertFalse(solution.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void itContainsBlock() { | ||
assertTrue(solution.containsBlock(block)); | ||
} | ||
|
||
@Test | ||
public void pollReturnPushedPosition() { | ||
assertEquals(blockPosition, solution.poll()); | ||
} | ||
} | ||
} |