Skip to content

Commit fb28bcd

Browse files
Add UserProperties class and unit tests
--- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/4d/4D-NetKit?shareId=XXXX-XXXX-XXXX-XXXX).
1 parent f4cdac1 commit fb28bcd

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
property userId : Text
2+
property userName : Text
3+
property userEmail : Text
4+
property userRole : Text
5+
6+
Class constructor($userId : Text; $userName : Text; $userEmail : Text; $userRole : Text)
7+
This.userId := $userId
8+
This.userName := $userName
9+
This.userEmail := $userEmail
10+
This.userRole := $userRole
11+
12+
Function getUserId() : Text
13+
return This.userId
14+
15+
Function setUserId($userId : Text)
16+
This.userId := $userId
17+
18+
Function getUserName() : Text
19+
return This.userName
20+
21+
Function setUserName($userName : Text)
22+
This.userName := $userName
23+
24+
Function getUserEmail() : Text
25+
return This.userEmail
26+
27+
Function setUserEmail($userEmail : Text)
28+
This.userEmail := $userEmail
29+
30+
Function getUserRole() : Text
31+
return This.userRole
32+
33+
Function setUserRole($userRole : Text)
34+
This.userRole := $userRole
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Class UserPropertiesTest
2+
3+
Function testInitialization()
4+
var $userProperties : cs.UserProperties
5+
$userProperties:=cs.UserProperties.new("1"; "John Doe"; "[email protected]"; "admin")
6+
7+
ASSERT($userProperties.getUserId()="1")
8+
ASSERT($userProperties.getUserName()="John Doe")
9+
ASSERT($userProperties.getUserEmail()="[email protected]")
10+
ASSERT($userProperties.getUserRole()="admin")
11+
12+
Function testGettersAndSetters()
13+
var $userProperties : cs.UserProperties
14+
$userProperties:=cs.UserProperties.new("1"; "John Doe"; "[email protected]"; "admin")
15+
16+
$userProperties.setUserId("2")
17+
ASSERT($userProperties.getUserId()="2")
18+
19+
$userProperties.setUserName("Jane Doe")
20+
ASSERT($userProperties.getUserName()="Jane Doe")
21+
22+
$userProperties.setUserEmail("[email protected]")
23+
ASSERT($userProperties.getUserEmail()="[email protected]")
24+
25+
$userProperties.setUserRole("user")
26+
ASSERT($userProperties.getUserRole()="user")
27+
28+
Function testDifferentInputs()
29+
var $userProperties : cs.UserProperties
30+
$userProperties:=cs.UserProperties.new(""; ""; ""; "")
31+
32+
ASSERT($userProperties.getUserId()="")
33+
ASSERT($userProperties.getUserName()="")
34+
ASSERT($userProperties.getUserEmail()="")
35+
ASSERT($userProperties.getUserRole()="")
36+
37+
$userProperties.setUserId("3")
38+
$userProperties.setUserName("Alice")
39+
$userProperties.setUserEmail("[email protected]")
40+
$userProperties.setUserRole("guest")
41+
42+
ASSERT($userProperties.getUserId()="3")
43+
ASSERT($userProperties.getUserName()="Alice")
44+
ASSERT($userProperties.getUserEmail()="[email protected]")
45+
ASSERT($userProperties.getUserRole()="guest")

0 commit comments

Comments
 (0)