diff --git a/Project/Sources/Classes/UserProperties.4dm b/Project/Sources/Classes/UserProperties.4dm new file mode 100644 index 0000000..c8d184a --- /dev/null +++ b/Project/Sources/Classes/UserProperties.4dm @@ -0,0 +1,34 @@ +property userId : Text +property userName : Text +property userEmail : Text +property userRole : Text + +Class constructor($userId : Text; $userName : Text; $userEmail : Text; $userRole : Text) + This.userId := $userId + This.userName := $userName + This.userEmail := $userEmail + This.userRole := $userRole + +Function getUserId() : Text + return This.userId + +Function setUserId($userId : Text) + This.userId := $userId + +Function getUserName() : Text + return This.userName + +Function setUserName($userName : Text) + This.userName := $userName + +Function getUserEmail() : Text + return This.userEmail + +Function setUserEmail($userEmail : Text) + This.userEmail := $userEmail + +Function getUserRole() : Text + return This.userRole + +Function setUserRole($userRole : Text) + This.userRole := $userRole diff --git a/Project/Sources/Classes/UserProperties.test.4dm b/Project/Sources/Classes/UserProperties.test.4dm new file mode 100644 index 0000000..f7335d8 --- /dev/null +++ b/Project/Sources/Classes/UserProperties.test.4dm @@ -0,0 +1,45 @@ +Class UserPropertiesTest + +Function testInitialization() + var $userProperties : cs.UserProperties + $userProperties:=cs.UserProperties.new("1"; "John Doe"; "john.doe@example.com"; "admin") + + ASSERT($userProperties.getUserId()="1") + ASSERT($userProperties.getUserName()="John Doe") + ASSERT($userProperties.getUserEmail()="john.doe@example.com") + ASSERT($userProperties.getUserRole()="admin") + +Function testGettersAndSetters() + var $userProperties : cs.UserProperties + $userProperties:=cs.UserProperties.new("1"; "John Doe"; "john.doe@example.com"; "admin") + + $userProperties.setUserId("2") + ASSERT($userProperties.getUserId()="2") + + $userProperties.setUserName("Jane Doe") + ASSERT($userProperties.getUserName()="Jane Doe") + + $userProperties.setUserEmail("jane.doe@example.com") + ASSERT($userProperties.getUserEmail()="jane.doe@example.com") + + $userProperties.setUserRole("user") + ASSERT($userProperties.getUserRole()="user") + +Function testDifferentInputs() + var $userProperties : cs.UserProperties + $userProperties:=cs.UserProperties.new(""; ""; ""; "") + + ASSERT($userProperties.getUserId()="") + ASSERT($userProperties.getUserName()="") + ASSERT($userProperties.getUserEmail()="") + ASSERT($userProperties.getUserRole()="") + + $userProperties.setUserId("3") + $userProperties.setUserName("Alice") + $userProperties.setUserEmail("alice@example.com") + $userProperties.setUserRole("guest") + + ASSERT($userProperties.getUserId()="3") + ASSERT($userProperties.getUserName()="Alice") + ASSERT($userProperties.getUserEmail()="alice@example.com") + ASSERT($userProperties.getUserRole()="guest")