Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sp21-cs242-assignment1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xinyupi2
sp21-cs242-assignment1
Commits
a5f44e78
Commit
a5f44e78
authored
4 years ago
by
FrederickPi1969
Browse files
Options
Downloads
Patches
Plain Diff
Add testcase for player declaring colo with Wild
parent
8746825f
No related branches found
No related tags found
1 merge request
!1
Implementation of <assignment-1.0>
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
out/test/sp21-cs242-assignment1/PlayerTest.class
+0
-0
0 additions, 0 deletions
out/test/sp21-cs242-assignment1/PlayerTest.class
src/Test/PlayerTest.java
+32
-0
32 additions, 0 deletions
src/Test/PlayerTest.java
with
32 additions
and
0 deletions
out/test/sp21-cs242-assignment1/PlayerTest.class
+
0
−
0
View file @
a5f44e78
No preview for this file type
This diff is collapsed.
Click to expand it.
src/Test/PlayerTest.java
+
32
−
0
View file @
a5f44e78
...
...
@@ -21,6 +21,7 @@ class PlayerTest {
@Test
/**
* Test 1
* Test when a card is played, it goes to the discard pile
* Run 100 times to cancel randomness
*/
...
...
@@ -46,6 +47,7 @@ class PlayerTest {
/**
* Test 2
* Test the situation where player choose to draw a card
* Run 100 times to cancel randomness
*/
...
...
@@ -82,4 +84,34 @@ class PlayerTest {
game
.
gameStart
();
assert
(
game
.
rounds
==
7
);
}
/**
* Test 4
* Test when a player plays a wild card and declare the matchable color as "red",
* the game state (controlled by ruleController) is properly updated.
* Notice the declaration is hard-coded in stage assignment-1.0
*/
@Test
void
testPlayerDeclareColorWithWild
()
{
Game
game
=
null
;
Player
player
=
null
;
int
wildCardID
=
-
1
;
boolean
hasWild
=
false
;
while
(!
hasWild
)
{
game
=
new
Game
(
1
);
player
=
game
.
players
.
get
(
0
);
for
(
int
cardID
:
player
.
getCards
())
{
if
(
cardID
>=
101
&&
cardID
<=
104
)
{
wildCardID
=
cardID
;
hasWild
=
true
;
break
;
// the player has a wild card
}
}
}
player
.
optionPlayOwnedCard
(
wildCardID
);
assert
(
game
.
ruler
.
getMatchableColor
().
equals
(
"red"
));
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment