@@ -71,4 +71,51 @@ final class UnitNCRoomParticipantTest: TestBaseRealm {
7171
7272 XCTAssertEqual ( sorted, expectedParticipants)
7373 }
74+
75+ func testInitWithDictionary( ) throws {
76+ let dataJson = """
77+ {
78+ " roomToken " : " tok3n " ,
79+ " inCall " : 7,
80+ " lastPing " : 1761683745,
81+ " sessionIds " : [
82+ " session1 " ,
83+ " session2 "
84+ ],
85+ " participantType " : 1,
86+ " attendeeId " : 72,
87+ " actorId " : " admin " ,
88+ " actorType " : " users " ,
89+ " displayName " : " admin " ,
90+ " permissions " : 254,
91+ " attendeePermissions " : 0,
92+ " attendeePin " : " " ,
93+ " phoneNumber " : " " ,
94+ " callId " : " " ,
95+ " status " : " busy " ,
96+ " statusIcon " : " 💬 " ,
97+ " statusMessage " : " In a call " ,
98+ " statusClearAt " : null
99+ }
100+ """
101+
102+ // swiftlint:disable:next force_cast
103+ let participantdict = try JSONSerialization . jsonObject ( with: dataJson. data ( using: . utf8) !) as! [ String : Any ]
104+ let participant = NCRoomParticipant ( dictionary: participantdict)
105+
106+ XCTAssertEqual ( participant. attendeeId, 72 )
107+ XCTAssertEqual ( participant. actorId, " admin " )
108+ XCTAssertEqual ( participant. actorType, . user)
109+ XCTAssertEqual ( participant. participantType, . owner)
110+ XCTAssertEqual ( participant. displayName, " admin " )
111+ XCTAssertEqual ( participant. lastPing, 1761683745 )
112+ XCTAssertEqual ( participant. sessionIds ? [ 0 ] , " session1 " )
113+ XCTAssertEqual ( participant. sessionIds ? [ 1 ] , " session2 " )
114+ XCTAssertEqual ( participant. inCall, [ . inCall, . withAudio, . withVideo] )
115+ XCTAssertEqual ( participant. status, " busy " )
116+ XCTAssertEqual ( participant. statusIcon, " 💬 " )
117+ XCTAssertEqual ( participant. statusMessage, " In a call " )
118+ XCTAssertNil ( participant. userId)
119+ }
120+
74121}
0 commit comments