-
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.
- Loading branch information
Showing
29 changed files
with
492 additions
and
81 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
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,84 @@ | ||
using Shouldly; | ||
using System.Text.Json; | ||
using Xunit; | ||
using ZoomNet.Json; | ||
using ZoomNet.Models; | ||
|
||
namespace ZoomNet.UnitTests.Models | ||
{ | ||
public class PhoneUserTests | ||
{ | ||
#region constants | ||
|
||
internal const string PHONE_USER = @"{ | ||
""id"": ""NL3cEpSdRc-c2t8aLoZqiw"", | ||
""phone_user_id"": ""u7pnC468TaS46OuNoEw6GA"", | ||
""email"": ""test_phone_user@testapi.com"", | ||
""name"": ""test phone user"", | ||
""extension_id"": ""CcrEGgmeQem1uyJsuIRKwA"", | ||
""extension_number"": 123, | ||
""status"": ""activate"", | ||
""calling_plans"": [ | ||
{ | ||
""type"": 600, | ||
""name"": ""Delhi billing"", | ||
""billing_account_id"": ""3WWAEiEjTj2IQuyDiKMd_A"", | ||
""billing_account_name"": ""Delhi billing"" | ||
} | ||
], | ||
""phone_numbers"": [ | ||
{ | ||
""id"": ""---M1padRvSUtw7YihN7sA"", | ||
""number"": ""14232058798"" | ||
} | ||
], | ||
""site"": { | ||
""id"": ""8f71O6rWT8KFUGQmJIFAdQ"", | ||
""name"": ""Test Site"" | ||
}, | ||
""department"": ""Test"", | ||
""cost_center"": ""Cost Test Center"" | ||
}"; | ||
|
||
#endregion | ||
|
||
#region tests | ||
|
||
[Fact] | ||
public void Parse_Json_PhoneUserTests() | ||
{ | ||
// Arrange | ||
|
||
// Act | ||
var result = JsonSerializer.Deserialize<PhoneUser>( | ||
PHONE_USER, JsonFormatter.SerializerOptions); | ||
|
||
// Assert | ||
result.Id.ShouldBe("NL3cEpSdRc-c2t8aLoZqiw"); | ||
result.PhoneUserId.ShouldBe("u7pnC468TaS46OuNoEw6GA"); | ||
result.Email.ShouldBe("test_phone_user@testapi.com"); | ||
result.Name.ShouldBe("test phone user"); | ||
result.ExtensionId.ShouldBe("CcrEGgmeQem1uyJsuIRKwA"); | ||
result.ExtensionNumber.ShouldBe(123); | ||
result.Status.ShouldBe(PhoneCallUserStatus.Active); | ||
result.CallingPlans.ShouldNotBeNull(); | ||
result.CallingPlans.Length.ShouldBe(1); | ||
result.PhoneNumbers.ShouldNotBeNull(); | ||
result.PhoneNumbers.Length.ShouldBe(1); | ||
result.Department.ShouldBe("Test"); | ||
result.CostCenter.ShouldBe("Cost Test Center"); | ||
result.Site.Id.ShouldBe("8f71O6rWT8KFUGQmJIFAdQ"); | ||
result.Site.Name.ShouldBe("Test Site"); | ||
|
||
var callingPlan = result.CallingPlans[0]; | ||
callingPlan.BillingAccountId.ShouldBe("3WWAEiEjTj2IQuyDiKMd_A"); | ||
callingPlan.BillingAccountName.ShouldBe("Delhi billing"); | ||
|
||
var phoneNumber = result.PhoneNumbers[0]; | ||
phoneNumber.PhoneNumberId.ShouldBe("---M1padRvSUtw7YihN7sA"); | ||
phoneNumber.PhoneNumber.ShouldBe("14232058798"); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
Source/ZoomNet.UnitTests/Resources/PhoneCallUserProfileTests.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
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,114 @@ | ||
using RichardSzalay.MockHttp; | ||
using Shouldly; | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using ZoomNet.Resources; | ||
|
||
namespace ZoomNet.UnitTests.Resources | ||
{ | ||
public class PhoneUserTests | ||
{ | ||
#region constants | ||
|
||
internal const string PHONE_USERS_PAGINATED_OBJECT = @"{ | ||
""next_page_token"": ""F2qwertyg5eIqRRgC2YMauur8ZHUaJqtS3i"", | ||
""page_size"": 1, | ||
""total_records"": 10, | ||
""users"": [ | ||
{ | ||
""id"": ""NL3cEpSdRc-c2t8aLoZqiw"", | ||
""phone_user_id"": ""u7pnC468TaS46OuNoEw6GA"", | ||
""email"": ""test_phone_user@testapi.com"", | ||
""name"": ""test phone user"", | ||
""extension_id"": ""CcrEGgmeQem1uyJsuIRKwA"", | ||
""extension_number"": 123, | ||
""status"": ""activate"", | ||
""calling_plans"": [ | ||
{ | ||
""type"": 600, | ||
""name"": ""Delhi billing"", | ||
""billing_account_id"": ""3WWAEiEjTj2IQuyDiKMd_A"", | ||
""billing_account_name"": ""Delhi billing"" | ||
} | ||
], | ||
""phone_numbers"": [ | ||
{ | ||
""id"": ""---M1padRvSUtw7YihN7sA"", | ||
""number"": ""14232058798"" | ||
} | ||
], | ||
""site"": { | ||
""id"": ""8f71O6rWT8KFUGQmJIFAdQ"", | ||
""name"": ""Test Site"" | ||
}, | ||
""department"": ""Test"", | ||
""cost_center"": ""Cost Test Center"" | ||
} | ||
] | ||
}"; | ||
|
||
#endregion | ||
|
||
#region tests | ||
|
||
[Fact] | ||
public async Task GetPhoneUsersPaginatedResponseTestsAsync() | ||
{ | ||
// Arrange | ||
var pageSize = 1; | ||
|
||
var mockHttp = new MockHttpMessageHandler(); | ||
mockHttp | ||
.Expect( | ||
HttpMethod.Get, | ||
Utils.GetZoomApiUri("phone/users")) | ||
.Respond( | ||
"application/json", | ||
PHONE_USERS_PAGINATED_OBJECT); | ||
|
||
var client = Utils.GetFluentClient(mockHttp); | ||
var phone = new Phone(client); | ||
|
||
// Act | ||
var result = await phone | ||
.ListPhoneUsersAsync(pageSize: pageSize) | ||
.ConfigureAwait(true); | ||
|
||
// Assert | ||
mockHttp.VerifyNoOutstandingExpectation(); | ||
mockHttp.VerifyNoOutstandingRequest(); | ||
result.NextPageToken.ShouldNotBeNullOrEmpty(); | ||
result.PageSize.ShouldBe(1); | ||
result.TotalRecords.ShouldBe(10); | ||
result.Records.ShouldNotBeNull(); | ||
result.Records.Length.ShouldBe(1); | ||
result.Records[0].Id.ShouldBe("NL3cEpSdRc-c2t8aLoZqiw"); | ||
result.Records[0].PhoneNumbers[0].PhoneNumberId.ShouldBe("---M1padRvSUtw7YihN7sA"); | ||
result.Records[0].PhoneNumbers[0].PhoneNumber.ShouldBe("14232058798"); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0)] | ||
[InlineData(101)] | ||
public void InvalidPageSize_GetPhoneUsersPaginatedResponseTests(int pageSize) | ||
{ | ||
// Arrange | ||
var mockHttp = new MockHttpMessageHandler(); | ||
|
||
var client = Utils.GetFluentClient(mockHttp); | ||
var phone = new Phone(client); | ||
|
||
// Act and Assert | ||
var exception = Assert.Throws<ArgumentOutOfRangeException>(() => phone | ||
.ListPhoneUsersAsync(pageSize: pageSize) | ||
.ConfigureAwait(true)); | ||
|
||
exception.ParamName.ShouldBe(nameof(pageSize)); | ||
exception.Message.ShouldStartWith("Records per page must be between 1 and 100"); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
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
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.