1
+ import entities .user_entities .User ;
2
+ import data_access .UserDatabase ;
3
+ import org .junit .jupiter .api .Assertions ;
4
+ import org .junit .jupiter .api .Test ;
5
+
6
+ import java .io .File ;
7
+ import java .util .List ;
8
+
9
+ public class UserDatabaseTest {
10
+ @ Test
11
+ public void addingFilesRightEmailAndUser (){
12
+ File accounts = new File ("Test3" );
13
+ UserDatabase accountDatabase = new UserDatabase (accounts );
14
+ accountDatabase .
createUser (
"MadhavGopakumar" ,
"123" ,
"[email protected] " ,
"Basic" );
15
+ Assertions .
assertTrue (
accountDatabase .
UserExists (
"MadhavGopakumar" ,
"[email protected] " ));
16
+ }
17
+ @ Test
18
+ public void addingMultipleFiles (){
19
+ File accounts = new File ("Test3" );
20
+ UserDatabase accountDatabase = new UserDatabase (accounts );
21
+ accountDatabase .
createUser (
"MeenakshiGopakumar" ,
"123" ,
"[email protected] " ,
"Basic" );
22
+ Assertions .
assertTrue (
accountDatabase .
UserExists (
"MeenakshiGopakumar" ,
"[email protected] " ));
23
+ }
24
+ @ Test
25
+ public void rightEmailWrongUser (){
26
+ File accounts = new File ("Test3" );
27
+ UserDatabase accountDatabase = new UserDatabase (accounts );
28
+ accountDatabase .
createUser (
"MadhavGopakumar" ,
"123" ,
"[email protected] " ,
"Basic" );
29
+ Assertions .
assertTrue (
accountDatabase .
UserExists (
"MadG" ,
"[email protected] " ));
30
+ }
31
+ @ Test
32
+ public void rightUserWrongEmail (){
33
+ File accounts = new File ("Test3" );
34
+ UserDatabase accountDatabase = new UserDatabase (accounts );
35
+ Assertions .assertTrue (accountDatabase .UserExists ("MeenakshiGopakumar" , "ma" ));
36
+ }
37
+ @ Test
38
+ public void listedUsers (){
39
+ File accounts = new File ("Test3" );
40
+ UserDatabase accountDatabase = new UserDatabase (accounts );
41
+ accountDatabase .
createUser (
"MeenakshiGopakumar" ,
"123" ,
"[email protected] " ,
"Basic" );
42
+ List <User > lst = accountDatabase .getList ();
43
+ String email = lst .get (0 ).getEmail ();
44
+ System .out .println (email );
45
+ Assertions .
assertTrue (
email .
equals (
"[email protected] " ));
46
+ }
47
+
48
+ @ Test
49
+ public void userGot () {
50
+ File accounts = new File ("Test3" );
51
+ UserDatabase accountDatabase = new UserDatabase (accounts );
52
+ accountDatabase .
createUser (
"MeenakshiGopakumar" ,
"123" ,
"[email protected] " ,
"Basic" );
53
+ User user = accountDatabase .getUser ("MeenakshiGopakumar" );
54
+ String email = user .getEmail ();
55
+ Assertions .
assertTrue (
email .
equals (
"[email protected] " ));
56
+ }
57
+
58
+ }
0 commit comments