Skip to content

Commit 957729e

Browse files
committed
Added a junit test for popUP script.
Added intellij folder path to .gitignore
1 parent bd291ed commit 957729e

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ local.properties
5858
*.tlb
5959
*.tli
6060
*.tlh
61-
*.tmp
6261
*.vspscc
6362
.builds
6463
*.dotCover
@@ -182,10 +181,12 @@ JavaGame.ipr
182181
JavaGame.iws
183182
JavaGame.iml
184183
out/
184+
.idea/
185185

186186
###############
187187
## Debugging ##
188188
###############
189189

190190
.log.txt
191191
/.gradle/
192+
Package game.png

src/com/redomar/game/script/PopUp.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@
77
public class PopUp{
88

99
private JFrame frame;
10+
public boolean active;
1011

1112
public PopUp(){
12-
frame = Game.getFrame();
13+
active = true;
1314
}
1415

1516
public int Warn(String msg){
1617
Object[] options = {"Continue"};
17-
return JOptionPane.showOptionDialog(frame, msg, "Notice", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE,
18-
null, options, options[0]);
18+
if (active) {
19+
frame = Game.getFrame();
20+
return JOptionPane.showOptionDialog(frame, msg, "Notice", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE,
21+
null, options, options[0]);
22+
}
23+
else
24+
return 1;
1925
}
2026
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.redomar.game.script;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
6+
import static org.junit.Assert.*;
7+
8+
public class PopUpTest {
9+
private PopUp popUp;
10+
11+
@Before
12+
public void setUp() throws Exception {
13+
popUp = new PopUp();
14+
popUp.active = false;
15+
}
16+
17+
@Test
18+
public void warnIntEfflux() throws Exception {
19+
assertEquals(1,popUp.Warn("TEST"));
20+
}
21+
22+
}

0 commit comments

Comments
 (0)