-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/multiple_devices_per_participant' into develop
- Loading branch information
Showing
7 changed files
with
357 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Newtonsoft.Json; | ||
using Shouldly; | ||
using Xunit; | ||
using ZoomNet.Models; | ||
|
||
namespace StrongGrid.UnitTests.Resources | ||
{ | ||
public class DashboardParticipantTests | ||
{ | ||
#region FIELDS | ||
|
||
internal const string SINGLE_DASHBOARDPARTICIPANT_JSON = @"{ | ||
'id': 'd52f19c548b88490b5d16fcbd38', | ||
'user_id': '32dsfsd4g5gd', | ||
'user_name': 'dojo', | ||
'device': 'Unknown', | ||
'ip_address': '127.0.0.1', | ||
'location': 'New York', | ||
'network_type': 'Wired', | ||
'microphone': 'Plantronics BT600', | ||
'camera': 'FaceTime HD Camera', | ||
'speaker': 'Plantronics BT600', | ||
'data_center': 'SC', | ||
'full_data_center': 'United States;United States (US03_SC CRC)', | ||
'connection_type': 'P2P', | ||
'join_time': '2019-09-07T13:15:02.837Z', | ||
'leave_time': '2019-09-07T13:15:09.837Z', | ||
'share_application': false, | ||
'share_desktop': true, | ||
'share_whiteboard': true, | ||
'recording': false, | ||
'status': 'in_waiting_room', | ||
'pc_name': 'dojo\'s pc', | ||
'domain': 'Dojo-workspace', | ||
'mac_addr': ' 00:0a:95:9d:68:16', | ||
'harddisk_id': 'sed proident in', | ||
'version': '4.4.55383.0716', | ||
'leave_reason': 'Dojo left the meeting.<br>Reason: Host ended the meeting.', | ||
'sip_uri': 'sip:[email protected]:11029', | ||
'from_sip_uri': 'sip:[email protected]:11029', | ||
'role': 'panelist' | ||
}"; | ||
|
||
#endregion | ||
|
||
[Fact] | ||
public void Parse_json() | ||
{ | ||
// Arrange | ||
|
||
// Act | ||
var result = JsonConvert.DeserializeObject<DashboardParticipant>(SINGLE_DASHBOARDPARTICIPANT_JSON); | ||
|
||
// Assert | ||
result.ShouldNotBeNull(); | ||
result.Devices.ShouldNotBeNull(); | ||
result.Devices.Length.ShouldBe(1); | ||
result.Devices[0].ShouldBe(ParticipantDevice.Unknown); | ||
} | ||
} | ||
} |
147 changes: 147 additions & 0 deletions
147
Source/ZoomNet.UnitTests/Utilities/ParticipantDeviceConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
using Newtonsoft.Json; | ||
using Shouldly; | ||
using System; | ||
using System.IO; | ||
using System.Text; | ||
using Xunit; | ||
using ZoomNet.Models; | ||
using ZoomNet.Utilities; | ||
|
||
namespace StrongGrid.UnitTests.Utilities | ||
{ | ||
public class ParticipantDeviceConverterTests | ||
{ | ||
[Fact] | ||
public void Properties() | ||
{ | ||
// Act | ||
var converter = new ParticipantDeviceConverter(); | ||
|
||
// Assert | ||
converter.CanRead.ShouldBeTrue(); | ||
converter.CanWrite.ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void CanConvert() | ||
{ | ||
// Act | ||
var converter = new ParticipantDeviceConverter(); | ||
|
||
// Assert | ||
converter.CanConvert(typeof(string)).ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void Write_single() | ||
{ | ||
// Arrange | ||
var sb = new StringBuilder(); | ||
var sw = new StringWriter(sb); | ||
var writer = new JsonTextWriter(sw); | ||
|
||
var value = new[] | ||
{ | ||
ParticipantDevice.Windows | ||
}; | ||
|
||
var serializer = new JsonSerializer(); | ||
|
||
var converter = new ParticipantDeviceConverter(); | ||
|
||
// Act | ||
converter.WriteJson(writer, value, serializer); | ||
var result = sb.ToString(); | ||
|
||
// Assert | ||
result.ShouldBe("\"Windows\""); | ||
} | ||
[Fact] | ||
public void Write_multiple() | ||
{ | ||
// Arrange | ||
var sb = new StringBuilder(); | ||
var sw = new StringWriter(sb); | ||
var writer = new JsonTextWriter(sw); | ||
|
||
var value = new[] | ||
{ | ||
ParticipantDevice.Unknown, | ||
ParticipantDevice.Phone | ||
}; | ||
|
||
var serializer = new JsonSerializer(); | ||
|
||
var converter = new ParticipantDeviceConverter(); | ||
|
||
// Act | ||
converter.WriteJson(writer, value, serializer); | ||
var result = sb.ToString(); | ||
|
||
// Assert | ||
result.ShouldBe("\"Unknown + Phone\""); | ||
} | ||
|
||
[Theory] | ||
[InlineDataAttribute("", ParticipantDevice.Unknown)] | ||
[InlineDataAttribute("Unknown", ParticipantDevice.Unknown)] | ||
[InlineDataAttribute("Android", ParticipantDevice.Android)] | ||
[InlineDataAttribute("Phone", ParticipantDevice.Phone)] | ||
[InlineDataAttribute("iOs", ParticipantDevice.IOS)] | ||
[InlineDataAttribute("H.323/SIP", ParticipantDevice.Sip)] | ||
[InlineDataAttribute("Windows", ParticipantDevice.Windows)] | ||
public void Read_single(string value, ParticipantDevice expectedValue) | ||
{ | ||
// Arrange | ||
var json = $"'{value}'"; | ||
|
||
var textReader = new StringReader(json); | ||
var jsonReader = new JsonTextReader(textReader); | ||
var objectType = (Type)null; | ||
var existingValue = (object)null; | ||
var serializer = new JsonSerializer(); | ||
|
||
var converter = new ParticipantDeviceConverter(); | ||
|
||
// Act | ||
jsonReader.Read(); | ||
var result = converter.ReadJson(jsonReader, objectType, existingValue, serializer); | ||
|
||
// Assert | ||
result.ShouldNotBeNull(); | ||
result.ShouldBeOfType<ParticipantDevice[]>(); | ||
|
||
var resultAsArray = (ParticipantDevice[])result; | ||
resultAsArray.Length.ShouldBe(1); | ||
resultAsArray[0].ShouldBe(expectedValue); | ||
} | ||
|
||
[Fact] | ||
public void Read_multiple() | ||
{ | ||
// Arrange | ||
var json = "'Unknown + Phone'"; | ||
|
||
var textReader = new StringReader(json); | ||
var jsonReader = new JsonTextReader(textReader); | ||
var objectType = (Type)null; | ||
var existingValue = (object)null; | ||
var serializer = new JsonSerializer(); | ||
|
||
var converter = new ParticipantDeviceConverter(); | ||
|
||
// Act | ||
jsonReader.Read(); | ||
var result = converter.ReadJson(jsonReader, objectType, existingValue, serializer); | ||
|
||
// Assert | ||
result.ShouldNotBeNull(); | ||
result.ShouldBeOfType<ParticipantDevice[]>(); | ||
|
||
var resultAsArray = (ParticipantDevice[])result; | ||
resultAsArray.Length.ShouldBe(2); | ||
resultAsArray[0].ShouldBe(ParticipantDevice.Unknown); | ||
resultAsArray[1].ShouldBe(ParticipantDevice.Phone); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.