-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmailTests.java
More file actions
98 lines (85 loc) · 2.15 KB
/
Copy pathEmailTests.java
File metadata and controls
98 lines (85 loc) · 2.15 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package tests;
import junit.framework.TestCase;
import models.Student;
import models.UserFactory;
import models.UserType;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class EmailTests extends TestCase {
private Student stud;
public EmailTests(String name) {
super(name);
}
@Before
public void setUp() {
try {
this.stud = (Student) UserFactory.createUser(UserType.STUDENT);
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
@Test
public void testEmailCorrect() {
this.stud.setEmail("ionutpetre.ro@gmail.com");
assertEquals("ionutpetre.ro@gmail.com", this.stud.getEmail());
}
@Test
public void testEmailWrong1() {
try {
this.stud.setEmail(null);
} catch(Exception ex) {
System.out.println(ex.toString());
assertSame(null, this.stud.getEmail());
}
}
@Test(expected = AssertionError.class)
public void testEmailWrong2() {
try {
this.stud.setEmail("ionutpetre");
} catch(Exception ex) {
System.out.println(ex.toString());
assertEquals("ionutpetre", this.stud.getEmail());
}
}
@Test(expected = AssertionError.class)
public void testEmailWrong3() {
try {
this.stud.setEmail("ionutpetre.ro");
} catch(Exception ex) {
System.out.println(ex.toString());
assertEquals("ionutpetre.ro", this.stud.getEmail());
}
}
@Test(expected = AssertionError.class)
public void testEmailWrong4() {
try {
this.stud.setEmail("ionutpetre.ro@");
} catch(Exception ex) {
System.out.println(ex.toString());
assertEquals("ionutpetre.ro@", this.stud.getEmail());
}
}
@Test(expected = AssertionError.class)
public void testEmailWrong5() {
try {
this.stud.setEmail("ionutpetre.ro@gmail");
} catch(Exception ex) {
System.out.println(ex.toString());
assertEquals("ionutpetre.ro@gmail", this.stud.getEmail());
}
}
@Test(expected = AssertionError.class)
public void testEmailWrong6() {
try {
this.stud.setEmail("ionutpetre.ro@gmail.");
} catch(Exception ex) {
System.out.println(ex.toString());
assertEquals("ionutpetre.ro@gmail.", this.stud.getEmail());
}
}
@After
public void tearDown() throws Exception {
this.stud = null;
}
}