Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
calculator
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
PIERRON Laurent
calculator
Commits
803d4492
Commit
803d4492
authored
2 years ago
by
Luquor
Browse files
Options
Downloads
Patches
Plain Diff
Couverture à 98% des tests
parent
478c6893
No related branches found
No related tags found
No related merge requests found
Pipeline
#10553
failed
2 years ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/fr/nancy/iut/UserInterfaceTest.java
+64
-0
64 additions, 0 deletions
src/test/java/fr/nancy/iut/UserInterfaceTest.java
with
64 additions
and
0 deletions
src/test/java/fr/nancy/iut/UserInterfaceTest.java
0 → 100644
+
64
−
0
View file @
803d4492
package
fr.nancy.iut
;
import
org.junit.jupiter.api.Test
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
public
class
UserInterfaceTest
{
@Test
public
void
testConstructor
()
{
UserInterface
ui
=
new
UserInterface
(
new
CalcEngine
());
assertTrue
(
ui
.
isVisible
(),
"User interface should be visible"
);
}
@Test
public
void
testSetVisible
()
{
UserInterface
ui
=
new
UserInterface
(
new
CalcEngine
());
ui
.
setVisible
(
false
);
assertFalse
(
ui
.
isVisible
(),
"User interface should not be visible"
);
}
@Test
public
void
testActionPerformed
()
{
UserInterface
ui
=
new
UserInterface
(
new
CalcEngine
());
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"0"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"1"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"2"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"3"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"4"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"5"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"6"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"7"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"8"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"9"
));
assertEquals
(
"123456789"
,
ui
.
getDisplay
().
getText
(),
"Display should be 0123456789"
);
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"C"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"+"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"-"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"*"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"/"
));
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"="
));
assertEquals
(
"0"
,
ui
.
getDisplay
().
getText
(),
"Display should be 0 because of C button"
);
}
@Test
public
void
testShowInfo
()
{
CalcEngine
engine
=
new
CalcEngine
();
UserInterface
ui
=
new
UserInterface
(
engine
);
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"?"
));
assertEquals
(
"version 0.2"
,
ui
.
getStatus
().
getText
(),
"Status should be the version of the calculator"
);
ui
.
actionPerformed
(
new
java
.
awt
.
event
.
ActionEvent
(
ui
,
0
,
"?"
));
assertEquals
(
"Hacker T. Largebrain"
,
ui
.
getStatus
().
getText
(),
"Status should be "
);
}
}
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