forked from rcdosado/caesar-cipher-mvc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaesarModelTest.java
More file actions
57 lines (39 loc) · 1.22 KB
/
CaesarModelTest.java
File metadata and controls
57 lines (39 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import static org.junit.Assert.assertEquals;
import org.junit.*;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.rcd.mvc.*;
/**
* Tests for {@link CaesarModel}.
*
* @author rcdosado@gmail.com
*/
@RunWith(JUnit4.class)
public class CaesarModelTest {
CaesarModel theModel;
@Before
public void setUp(){
theModel = new CaesarModel();
}
@Test
public void testEncryption() {
theModel.setPlainText("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
assertEquals("XYZABCDEFGHIJKLMNOPQRSTUVW",theModel.getEncryptedString());
theModel.setPlainText("abcdefghijklmnopqrstuvwxyz");
assertEquals("xyzabcdefghijklmnopqrstuvw",theModel.getEncryptedString());
theModel.setPlainText("0123456789");
assertEquals("0123456789",theModel.getEncryptedString());
theModel.setPlainText(" ?$%^&*()!<>\'\";:");
assertEquals(" ?$%^&*()!<>\'\";:",theModel.getEncryptedString());
theModel.setPlainText("Carpenters");
assertEquals("Zxombkqbop",theModel.getEncryptedString());
}
@Test(expected=IllegalArgumentException.class)
public void testValidation(){
String emptyStr="";
String nullStr=null;
theModel.setPlainText(emptyStr);
theModel.setPlainText(nullStr);
}
}