Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
agile-java
/
ChessAndroid
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
26e06e47
authored
Jun 01, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QueenTest added
parent
43c0cc25
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
14 deletions
app/src/test/java/com/example/paktalin/agilejava_exercises/AllTests.java
app/src/test/java/com/example/paktalin/agilejava_exercises/pieces/KingTest.java
app/src/test/java/com/example/paktalin/agilejava_exercises/pieces/PawnTest.java
app/src/test/java/com/example/paktalin/agilejava_exercises/pieces/PieceTest.java
app/src/test/java/com/example/paktalin/agilejava_exercises/pieces/QueenTest.java
app/src/test/java/com/example/paktalin/agilejava_exercises/AllTests.java
View file @
26e06e47
package
com
.
example
.
paktalin
.
agilejava_exercises
;
package
com
.
example
.
paktalin
.
agilejava_exercises
;
import
com.example.paktalin.agilejava_exercises.moves.*
;
import
com.example.paktalin.agilejava_exercises.moves.*
;
import
com.example.paktalin.agilejava_exercises.pieces.KingTest
;
import
com.example.paktalin.agilejava_exercises.pieces.*
;
import
com.example.paktalin.agilejava_exercises.pieces.PawnTest
;
import
junit.framework.TestSuite
;
import
junit.framework.TestSuite
;
...
@@ -23,6 +22,7 @@ public class AllTests extends TestSuite {
...
@@ -23,6 +22,7 @@ public class AllTests extends TestSuite {
suite
.
addTestSuite
(
KingTest
.
class
);
suite
.
addTestSuite
(
KingTest
.
class
);
suite
.
addTestSuite
(
PawnTest
.
class
);
suite
.
addTestSuite
(
PawnTest
.
class
);
suite
.
addTestSuite
(
QueenTest
.
class
);
return
suite
;
return
suite
;
}
}
...
...
app/src/test/java/com/example/paktalin/agilejava_exercises/pieces/KingTest.java
View file @
26e06e47
...
@@ -9,7 +9,7 @@ public class KingTest extends PieceTest {
...
@@ -9,7 +9,7 @@ public class KingTest extends PieceTest {
@Override
@Override
void
setExpectedRepresentation
()
{
void
setExpectedRepresentation
()
{
expectedR
epresentation
=
'k'
;
r
epresentation
=
'k'
;
}
}
@Override
@Override
...
@@ -19,7 +19,7 @@ public class KingTest extends PieceTest {
...
@@ -19,7 +19,7 @@ public class KingTest extends PieceTest {
@Override
@Override
void
setExpectedStrength
()
{
void
setExpectedStrength
()
{
expectedS
trength
=
0
;
s
trength
=
0
;
}
}
}
}
app/src/test/java/com/example/paktalin/agilejava_exercises/pieces/PawnTest.java
View file @
26e06e47
...
@@ -9,7 +9,7 @@ import static com.example.paktalin.agilejava_exercises.pieces.Piece.Color.Black;
...
@@ -9,7 +9,7 @@ import static com.example.paktalin.agilejava_exercises.pieces.Piece.Color.Black;
public
class
PawnTest
extends
PieceTest
{
public
class
PawnTest
extends
PieceTest
{
@Override
@Override
void
setExpectedRepresentation
()
{
void
setExpectedRepresentation
()
{
expectedR
epresentation
=
'p'
;
r
epresentation
=
'p'
;
}
}
@Override
@Override
...
@@ -19,17 +19,17 @@ public class PawnTest extends PieceTest {
...
@@ -19,17 +19,17 @@ public class PawnTest extends PieceTest {
@Override
@Override
void
setExpectedStrength
()
{
void
setExpectedStrength
()
{
expectedS
trength
=
1
;
s
trength
=
1
;
}
}
@Override
@Override
public
void
testStrength
()
{
public
void
testStrength
()
{
super
.
testStrength
();
super
.
testStrength
();
expectedS
trength
=
0.5
;
s
trength
=
0.5
;
board
.
placePiece
(
createPiece
(
Black
),
"a6"
);
board
.
placePiece
(
createPiece
(
Black
),
"a6"
);
assertEquals
(
expectedS
trength
,
board
.
getPieceAtPosition
(
"a6"
).
getStrength
());
assertEquals
(
s
trength
,
board
.
getPieceAtPosition
(
"a6"
).
getStrength
());
assertEquals
(
expectedS
trength
,
board
.
getPieceAtPosition
(
"a7"
).
getStrength
());
assertEquals
(
s
trength
,
board
.
getPieceAtPosition
(
"a7"
).
getStrength
());
}
}
}
}
app/src/test/java/com/example/paktalin/agilejava_exercises/pieces/PieceTest.java
View file @
26e06e47
...
@@ -13,8 +13,8 @@ import static com.example.paktalin.agilejava_exercises.pieces.Piece.Color.*;
...
@@ -13,8 +13,8 @@ import static com.example.paktalin.agilejava_exercises.pieces.Piece.Color.*;
public
abstract
class
PieceTest
extends
TestCase
{
public
abstract
class
PieceTest
extends
TestCase
{
char
expectedR
epresentation
;
char
r
epresentation
;
double
expectedS
trength
;
double
s
trength
;
private
Position
position
=
Position
.
create
(
"a7"
);
private
Position
position
=
Position
.
create
(
"a7"
);
Board
board
;
Board
board
;
...
@@ -33,20 +33,20 @@ public abstract class PieceTest extends TestCase {
...
@@ -33,20 +33,20 @@ public abstract class PieceTest extends TestCase {
Piece
blackPiece
=
createPiece
(
Black
);
Piece
blackPiece
=
createPiece
(
Black
);
assertTrue
(
whitePiece
.
isWhite
());
assertTrue
(
whitePiece
.
isWhite
());
assertEquals
(
expectedR
epresentation
,
whitePiece
.
getRepresentation
());
assertEquals
(
r
epresentation
,
whitePiece
.
getRepresentation
());
assertTrue
(
blackPiece
.
isBlack
());
assertTrue
(
blackPiece
.
isBlack
());
assertEquals
(
getBlackRepresentation
(),
blackPiece
.
getRepresentation
());
assertEquals
(
getBlackRepresentation
(),
blackPiece
.
getRepresentation
());
}
}
private
char
getBlackRepresentation
()
{
private
char
getBlackRepresentation
()
{
return
Character
.
toUpperCase
(
expectedR
epresentation
);
return
Character
.
toUpperCase
(
r
epresentation
);
}
}
public
void
testStrength
()
{
public
void
testStrength
()
{
board
=
Board
.
createEmpty
();
board
=
Board
.
createEmpty
();
board
.
placePiece
(
createPiece
(
Black
),
position
);
board
.
placePiece
(
createPiece
(
Black
),
position
);
assertEquals
(
expectedS
trength
,
board
.
getPieceAtPosition
(
position
).
getStrength
());
assertEquals
(
s
trength
,
board
.
getPieceAtPosition
(
position
).
getStrength
());
}
}
}
}
app/src/test/java/com/example/paktalin/agilejava_exercises/pieces/QueenTest.java
0 → 100644
View file @
26e06e47
package
com
.
example
.
paktalin
.
agilejava_exercises
.
pieces
;
/**
* Created by Paktalin on 01/06/2018.
*/
public
class
QueenTest
extends
PieceTest
{
@Override
void
setExpectedRepresentation
()
{
representation
=
'q'
;
}
@Override
Piece
createPiece
(
Piece
.
Color
color
)
{
return
new
Queen
(
color
);
}
@Override
void
setExpectedStrength
()
{
strength
=
9
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment