From 9a8f80f134cb482c347de761005e658becd90bc8 Mon Sep 17 00:00:00 2001 From: ckoegel Date: Mon, 6 Jul 2026 15:07:53 -0400 Subject: [PATCH 1/7] SWI-7235 Update Api Unit Tests --- .../Unit/Api/CallsApiTests.cs | 531 ++++-------------- 1 file changed, 112 insertions(+), 419 deletions(-) diff --git a/src/Bandwidth.Standard.Test/Unit/Api/CallsApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/CallsApiTests.cs index 0021482a..ef1b3ddd 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/CallsApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/CallsApiTests.cs @@ -9,41 +9,46 @@ */ using System; -using System.IO; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using RestSharp; +using System.Net; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; using Bandwidth.Standard.Model; -using Moq; -using System.Net; namespace Bandwidth.Standard.Test.Unit.Api { /// - /// Class for testing CallsApi + /// CallsApi Unit Tests /// public class CallsApiTests : IDisposable { - private CallsApi instance; - private Mock mockClient; - private Mock mockAsynchronousClient; - private Configuration fakeConfiguration; + private readonly CallsApi instance; + + private readonly string accountId = Environment.GetEnvironmentVariable("BW_ACCOUNT_ID"); + private readonly string userNumber = Environment.GetEnvironmentVariable("USER_NUMBER"); + private readonly string bwNumber = Environment.GetEnvironmentVariable("BW_NUMBER"); + private readonly string voiceApplicationId = Environment.GetEnvironmentVariable("BW_VOICE_APPLICATION_ID"); + private readonly string callbackUrl = Environment.GetEnvironmentVariable("BASE_CALLBACK_URL"); + + private readonly string callId = "c-1234"; + private readonly string displayName = "C# SDK"; + private readonly CallbackMethodEnum answerMethod = CallbackMethodEnum.POST; + private readonly CallbackMethodEnum disconnectMethod = CallbackMethodEnum.GET; + private readonly double callTimeout = 30.0; + private readonly double callbackTimeout = 15.0; public CallsApiTests() { - mockClient = new Mock(); - mockAsynchronousClient = new Mock(); - fakeConfiguration = new Configuration(); - fakeConfiguration.BasePath = "https://voice.bandwidth.com/api/v2"; - fakeConfiguration.Username = "username"; - fakeConfiguration.Password = "password"; - instance = new CallsApi(mockClient.Object, mockAsynchronousClient.Object, fakeConfiguration); + Configuration configuration = new() + { + BasePath = "http://127.0.0.1:4010", + IgnoreOperationServers = true, + OAuthClientId = Environment.GetEnvironmentVariable("BW_CLIENT_ID"), + OAuthClientSecret = Environment.GetEnvironmentVariable("BW_CLIENT_SECRET") + }; + instance = new CallsApi(configuration); } public void Dispose() @@ -66,228 +71,113 @@ public void InstanceTest() [Fact] public void CreateCallTest() { - string accountId = "9900000"; - CreateCall createCall = new CreateCall( - to: "+19195551234", - from: "+19195554321", - applicationId: "1234-qwer-5679-tyui", - answerUrl: "https://www.myCallbackServer.example/webhooks/answer" - ); - CreateCallResponse callResponse = new CreateCallResponse( - applicationId: "04e88489-df02-4e34-a0ee-27a91849555f", - accountId: "9900000", - callId: "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", - to: "+19195551234", - from: "+19195554321", - callUrl: "https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", - answerMethod: CallbackMethodEnum.POST, - answerUrl: "https://myServer.example/bandwidth/webhooks/answer", - disconnectMethod: CallbackMethodEnum.POST + MachineDetectionConfiguration machineDetection = new( + mode: MachineDetectionModeEnum.Async, + detectionTimeout: 5.0, + silenceTimeout: 5.0, + speechThreshold: 5.0, + speechEndThreshold: 5.0, + delayResult: true, + callbackUrl: callbackUrl, + callbackMethod: CallbackMethodEnum.POST ); - var apiResponse = new ApiResponse(HttpStatusCode.Created, callResponse); - mockClient.Setup(x => x.Post("/accounts/{accountId}/calls", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.CreateCallWithHttpInfo(accountId, createCall); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.Created, response.StatusCode); - } - - /// - /// Test failed CreateCall Request - /// - [Fact] - public void CreateCallBadRequest() - { - string accountId = "9900000"; - CreateCall createCall = new CreateCall( - to: "invalidNumber", - from: "+19195554321", - applicationId: "1234-qwer-5679-tyui", - answerUrl: "https://www.myCallbackServer.example/webhooks/answer" + CreateCall createCall = new( + applicationId: voiceApplicationId, + to: userNumber, + from: bwNumber, + privacy: false, + displayName: displayName, + answerUrl: callbackUrl, + answerMethod: answerMethod, + disconnectUrl: callbackUrl, + disconnectMethod: disconnectMethod, + machineDetection: machineDetection, + callTimeout: callTimeout, + callbackTimeout: callbackTimeout ); - var apiResponse = new ApiResponse(HttpStatusCode.BadRequest, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/calls", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.CreateCall(accountId, createCall)); - - Assert.Equal("Error calling CreateCall: ", Exception.Message); - Assert.Equal(400, Exception.ErrorCode); - } + ApiResponse response = instance.CreateCallWithHttpInfo(accountId, createCall); - /// - /// Test unauthorized CreateCall Request - /// - [Fact] - public void CreateCallUnauthorizedRequest() - { - string accountId = "9900000"; - CreateCall createCall = new CreateCall( - to: "+19195551234", - from: "+19195554321", - applicationId: "1234-qwer-5679-tyui", - answerUrl: "https://www.myCallbackServer.example/webhooks/answer" - ); - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/calls", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.CreateCall(accountId, createCall)); - - Assert.Equal("Error calling CreateCall: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); + Assert.Equal(HttpStatusCode.Created, response.StatusCode); + Assert.IsType(response.Data); + Assert.Equal(36, response.Data.ApplicationId.Length); + Assert.Equal(7, response.Data.AccountId.Length); + Assert.Equal(47, response.Data.CallId.Length); + Assert.Equal(12, response.Data.To.Length); + Assert.Equal(12, response.Data.From.Length); + Assert.IsType(response.Data.EnqueuedTime); + Assert.IsType(response.Data.CallUrl); + Assert.IsType(response.Data.CallTimeout); + Assert.IsType(response.Data.CallbackTimeout); + Assert.IsType(response.Data.Tag); + Assert.IsType(response.Data.AnswerMethod); + Assert.IsType(response.Data.AnswerUrl); + Assert.IsType(response.Data.AnswerFallbackMethod); + Assert.IsType(response.Data.AnswerFallbackUrl); + Assert.IsType(response.Data.DisconnectMethod); + Assert.IsType(response.Data.DisconnectUrl); + Assert.IsType(response.Data.Username); + Assert.IsType(response.Data.Password); + Assert.IsType(response.Data.FallbackUsername); + Assert.IsType(response.Data.FallbackPassword); + Assert.IsType(response.Data.Priority); } - /// - /// Test forbidden CreateCall Request - /// - [Fact] - public void CreateCallForbiddenRequest() - { - string accountId = "9900000"; - CreateCall createCall = new CreateCall( - to: "+19195551234", - from: "+19195554321", - applicationId: "1234-qwer-5679-tyui", - answerUrl: "https://www.myCallbackServer.example/webhooks/answer" - ); - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/calls", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.CreateCall(accountId, createCall)); - - Assert.Equal("Error calling CreateCall: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); - } - /// /// Test GetCallState /// [Fact] public void GetCallStateTest() { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - - var apiResponse = new ApiResponse(HttpStatusCode.OK, new CallState()); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.GetCallStateWithHttpInfo(accountId, callId); + ApiResponse response = instance.GetCallStateWithHttpInfo(accountId, callId); - Assert.IsType>(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.Equal(36, response.Data.ApplicationId.Length); + Assert.Equal(7, response.Data.AccountId.Length); + Assert.Equal(47, response.Data.CallId.Length); + Assert.Equal(47, response.Data.ParentCallId.Length); + Assert.Equal(12, response.Data.To.Length); + Assert.Equal(12, response.Data.From.Length); + Assert.IsType(response.Data.Direction); + Assert.IsType(response.Data.State); + Assert.IsType>(response.Data.StirShaken); + Assert.IsType(response.Data.Identity); + Assert.IsType(response.Data.EnqueuedTime); + Assert.IsType(response.Data.StartTime); + Assert.IsType(response.Data.AnswerTime); + Assert.IsType(response.Data.EndTime); + Assert.IsType(response.Data.DisconnectCause); + Assert.IsType(response.Data.LastUpdate); } - /// - /// Test unauthorized GetCallState Request - /// - [Fact] - public void GetCallStateUnauthorizedRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GetCallState(accountId, callId)); - - Assert.Equal("Error calling GetCallState: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden GetCallState Request - /// - [Fact] - public void GetCallStateForbiddenRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GetCallState(accountId, callId)); - - Assert.Equal("Error calling GetCallState: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); - } - - /// - /// Test not found GetCallState Request - /// - [Fact] - public void GetCallStateNotFoundRequest() - { - string accountId = "9900000"; - string callId = "not a call id"; - - var apiResponse = new ApiResponse(HttpStatusCode.NotFound, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GetCallState(accountId, callId)); - - Assert.Equal("Error calling GetCallState: ", Exception.Message); - Assert.Equal(404, Exception.ErrorCode); - } - /// /// Test ListCalls /// [Fact] public void ListCallsTest() { - string accountId = "9900000"; - CallState callState = new CallState( - state: "answered" - ); - - var apiResponse = new ApiResponse>(HttpStatusCode.OK, new List() { callState }); - mockClient.Setup(x => x.Get>("/accounts/{accountId}/calls", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.ListCallsWithHttpInfo(accountId); + ApiResponse> response = instance.ListCallsWithHttpInfo(accountId, userNumber, bwNumber); - Assert.IsType>>(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); - } - - /// - /// Test unauthorized ListCalls Request - /// - [Fact] - public void ListCallsUnauthorizedRequest() - { - string accountId = "9900000"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse>(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Get>("/accounts/{accountId}/calls", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.ListCalls(accountId)); - - Assert.Equal("Error calling ListCalls: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden ListCalls Request - /// - [Fact] - public void ListCallsForbiddenRequest() - { - string accountId = "9900000"; - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse>(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Get>("/accounts/{accountId}/calls", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.ListCalls(accountId)); - - Assert.Equal("Error calling ListCalls: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); + Assert.IsType(response.Data[0]); + Assert.Equal(36, response.Data[0].ApplicationId.Length); + Assert.Equal(7, response.Data[0].AccountId.Length); + Assert.Equal(47, response.Data[0].CallId.Length); + Assert.Equal(47, response.Data[0].ParentCallId.Length); + Assert.Equal(12, response.Data[0].To.Length); + Assert.Equal(12, response.Data[0].From.Length); + Assert.IsType(response.Data[0].Direction); + Assert.IsType(response.Data[0].State); + Assert.IsType>(response.Data[0].StirShaken); + Assert.IsType(response.Data[0].Identity); + Assert.IsType(response.Data[0].EnqueuedTime); + Assert.IsType(response.Data[0].StartTime); + Assert.IsType(response.Data[0].AnswerTime); + Assert.IsType(response.Data[0].EndTime); + Assert.IsType(response.Data[0].DisconnectCause); + Assert.IsType(response.Data[0].LastUpdate); } /// @@ -296,147 +186,13 @@ public void ListCallsForbiddenRequest() [Fact] public void UpdateCallTest() { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - UpdateCall updateCall = new UpdateCall( - state: CallStateEnum.Completed, - redirectUrl: "https://myServer.example/bandwidth/webhooks/redirect", - redirectMethod: RedirectMethodEnum.POST, - username: "username", - password: "password", - redirectFallbackUrl: "https://myFallbackServer.example/bandwidth/webhooks/redirect", - redirectFallbackMethod: RedirectMethodEnum.POST, - fallbackUsername: "fallbackUsername", - fallbackPassword: "fallbackPassword", - tag: "My Custom Tag" + UpdateCall updateCall = new( + state: CallStateEnum.Active ); - var apiResponse = new ApiResponse(HttpStatusCode.OK, new CallState()); - mockClient.Setup(x => x.Post("/accounts/{accountId}/calls/{callId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.UpdateCallWithHttpInfo(accountId, callId, updateCall); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - } - - /// - /// Test failed UpdateCall Request - /// - [Fact] - public void UpdateCallBadRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - UpdateCall updateCall = new UpdateCall( - state: CallStateEnum.Completed, - redirectUrl: "https://myServer.example/bandwidth/webhooks/redirect", - redirectMethod: RedirectMethodEnum.POST, - username: "username", - password: "password", - redirectFallbackUrl: "https://myFallbackServer.example/bandwidth/webhooks/redirect", - redirectFallbackMethod: RedirectMethodEnum.POST, - fallbackUsername: "fallbackUsername", - fallbackPassword: "fallbackPassword", - tag: "My Custom Tag" - ); - - var apiResponse = new ApiResponse(HttpStatusCode.BadRequest, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/calls/{callId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.UpdateCallWithHttpInfo(accountId, callId, updateCall)); - - Assert.Equal("Error calling UpdateCall: ", Exception.Message); - Assert.Equal(400, Exception.ErrorCode); - } - - /// - /// Test unauthorized UpdateCall Request - /// - [Fact] - public void UpdateCallUnauthorizedRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - UpdateCall updateCall = new UpdateCall( - state: CallStateEnum.Completed, - redirectUrl: "https://myServer.example/bandwidth/webhooks/redirect", - redirectMethod: RedirectMethodEnum.POST, - username: "username", - password: "password", - redirectFallbackUrl: "https://myFallbackServer.example/bandwidth/webhooks/redirect", - redirectFallbackMethod: RedirectMethodEnum.POST, - fallbackUsername: "fallbackUsername", - fallbackPassword: "fallbackPassword", - tag: "My Custom Tag" - ); - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/calls/{callId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.UpdateCallWithHttpInfo(accountId, callId, updateCall)); - - Assert.Equal("Error calling UpdateCall: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden UpdateCall Request - /// - [Fact] - public void UpdateCallForbiddenRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - UpdateCall updateCall = new UpdateCall( - state: CallStateEnum.Completed, - redirectUrl: "https://myServer.example/bandwidth/webhooks/redirect", - redirectMethod: RedirectMethodEnum.POST, - username: "username", - password: "password", - redirectFallbackUrl: "https://myFallbackServer.example/bandwidth/webhooks/redirect", - redirectFallbackMethod: RedirectMethodEnum.POST, - fallbackUsername: "fallbackUsername", - fallbackPassword: "fallbackPassword", - tag: "My Custom Tag" - ); - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/calls/{callId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.UpdateCallWithHttpInfo(accountId, callId, updateCall)); - - Assert.Equal("Error calling UpdateCall: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); - } + ApiResponse response = instance.UpdateCallWithHttpInfo(accountId, callId, updateCall); - /// - /// Test not found UpdateCall Request - /// - [Fact] - public void UpdateCallNotFoundRequest() - { - string accountId = "9900000"; - string callId = "not a call id"; - UpdateCall updateCall = new UpdateCall( - state: CallStateEnum.Completed, - redirectUrl: "https://myServer.example/bandwidth/webhooks/redirect", - redirectMethod: RedirectMethodEnum.POST, - username: "username", - password: "password", - redirectFallbackUrl: "https://myFallbackServer.example/bandwidth/webhooks/redirect", - redirectFallbackMethod: RedirectMethodEnum.POST, - fallbackUsername: "fallbackUsername", - fallbackPassword: "fallbackPassword", - tag: "My Custom Tag" - ); - - var apiResponse = new ApiResponse(HttpStatusCode.NotFound, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/calls/{callId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.UpdateCallWithHttpInfo(accountId, callId, updateCall)); - - Assert.Equal("Error calling UpdateCall: ", Exception.Message); - Assert.Equal(404, Exception.ErrorCode); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); } /// @@ -445,74 +201,11 @@ public void UpdateCallNotFoundRequest() [Fact] public void UpdateCallBxmlTest() { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string body = " This is a test sentence."; + string updateCallBxml = ""; - var apiResponse = new ApiResponse(HttpStatusCode.NoContent, null); - mockClient.Setup(x => x.Put("/accounts/{accountId}/calls/{callId}/bxml", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.UpdateCallBxmlWithHttpInfo(accountId, callId, body); + ApiResponse response = instance.UpdateCallBxmlWithHttpInfo(accountId, callId, updateCallBxml); - Assert.IsType>(response); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } - - /// - /// Test unauthorized UpdateCallBxml Request - /// - [Fact] - public void UpdateCallBxmlUnauthorizedRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string body = " This is a test sentence."; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Put("/accounts/{accountId}/calls/{callId}/bxml", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.UpdateCallBxmlWithHttpInfo(accountId, callId, body)); - - Assert.Equal("Error calling UpdateCallBxml: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden UpdateCallBxml Request - /// - [Fact] - public void UpdateCallBxmlForbiddenRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string body = " This is a test sentence."; - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Put("/accounts/{accountId}/calls/{callId}/bxml", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.UpdateCallBxmlWithHttpInfo(accountId, callId, body)); - - Assert.Equal("Error calling UpdateCallBxml: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); - } - - /// - /// Test not found UpdateCallBxml Request - /// - [Fact] - public void UpdateCallBxmlNotFoundRequest() - { - string accountId = "9900000"; - string callId = "not a call id"; - string body = " This is a test sentence."; - - var apiResponse = new ApiResponse(HttpStatusCode.NotFound, null); - mockClient.Setup(x => x.Put("/accounts/{accountId}/calls/{callId}/bxml", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.UpdateCallBxmlWithHttpInfo(accountId, callId, body)); - - Assert.Equal("Error calling UpdateCallBxml: ", Exception.Message); - Assert.Equal(404, Exception.ErrorCode); - } } } From 66ee17ad9190a63fbd92ba8053a1d80e4630ab2f Mon Sep 17 00:00:00 2001 From: ckoegel Date: Mon, 6 Jul 2026 15:33:14 -0400 Subject: [PATCH 2/7] conferences and endpoints --- .../Unit/Api/ConferencesApiTests.cs | 272 ++++------- .../Unit/Api/EndpointsApiTests.cs | 427 +++--------------- 2 files changed, 153 insertions(+), 546 deletions(-) diff --git a/src/Bandwidth.Standard.Test/Unit/Api/ConferencesApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/ConferencesApiTests.cs index 5dd5b8e2..0557716d 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/ConferencesApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/ConferencesApiTests.cs @@ -11,39 +11,39 @@ using System; using System.IO; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using RestSharp; +using System.Net; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; using Bandwidth.Standard.Model; -using Moq; -using System.Net; namespace Bandwidth.Standard.Test.Unit.Api { /// - /// Class for testing ConferencesApi + /// ConferencesApi Unit Tests /// public class ConferencesApiTests : IDisposable { - private ConferencesApi instance; - private Mock mockClient; - private Mock mockAsynchronousClient; - private Configuration fakeConfiguration; + private readonly ConferencesApi instance; + + private readonly string accountId = Environment.GetEnvironmentVariable("BW_ACCOUNT_ID"); + private readonly string callbackUrl = Environment.GetEnvironmentVariable("BASE_CALLBACK_URL"); + + private readonly string callId = "c-1234"; + private readonly string conferenceId = "c-4321"; + private readonly string recordingId = "r-1234"; public ConferencesApiTests() { - mockClient = new Mock(); - mockAsynchronousClient = new Mock(); - fakeConfiguration = new Configuration(); - fakeConfiguration.BasePath = "https://voice.bandwidth.com/api/v2"; - fakeConfiguration.Username = "username"; - fakeConfiguration.Password = "password"; - instance = new ConferencesApi(mockClient.Object, mockAsynchronousClient.Object, fakeConfiguration); + Configuration configuration = new() + { + BasePath = "http://127.0.0.1:4010", + IgnoreOperationServers = true, + OAuthClientId = Environment.GetEnvironmentVariable("BW_CLIENT_ID"), + OAuthClientSecret = Environment.GetEnvironmentVariable("BW_CLIENT_SECRET") + }; + instance = new ConferencesApi(configuration); } public void Dispose() @@ -63,19 +63,13 @@ public void InstanceTest() /// /// Test DownloadConferenceRecording /// - [Fact] + [Fact(Skip = "Can't set the correct Accept header for Prism")] public void DownloadConferenceRecordingTest() { - string accountId = "9900000"; - string conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - - var apiResponse = new ApiResponse(HttpStatusCode.OK, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media",It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.DownloadConferenceRecordingWithHttpInfo(accountId, conferenceId, recordingId); + ApiResponse response = instance.DownloadConferenceRecordingWithHttpInfo(accountId, conferenceId, recordingId); - Assert.IsAssignableFrom>(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); } /// @@ -84,24 +78,17 @@ public void DownloadConferenceRecordingTest() [Fact] public void GetConferenceTest() { - string accountId = "9900000"; - string conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; - var conference = new Conference( - id: "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9", - name: "my-conference-name", - createdTime: new DateTime(2022, 06, 17, 22, 20, 00), - completedTime: new DateTime(2022, 06, 17, 22, 20, 00), - conferenceEventUrl: "https://myServer.example/bandwidth/webhooks/conferenceEvent", - conferenceEventMethod: CallbackMethodEnum.POST, - tag: "my custom tag" - ); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, conference); - mockClient.Setup(x => x.Get("/accounts/{accountId}/conferences/{conferenceId}",It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.GetConferenceWithHttpInfo(accountId, conferenceId); + ApiResponse response = instance.GetConferenceWithHttpInfo(accountId, conferenceId); - Assert.IsType>(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.Equal(50, response.Data.Id.Length); + Assert.IsType(response.Data.Name); + Assert.IsType(response.Data.CreatedTime); + Assert.IsType(response.Data.CompletedTime); + Assert.IsType(response.Data.ConferenceEventUrl); + Assert.IsType(response.Data.ConferenceEventMethod); + Assert.IsType(response.Data.Tag); } /// @@ -110,24 +97,16 @@ public void GetConferenceTest() [Fact] public void GetConferenceMemberTest() { - string accountId = "9900000"; - string conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; - string memberId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - ConferenceMember conferenceMember = new ConferenceMember( - callId: "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", - conferenceId: "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9", - memberUrl: "https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/members/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", - mute: false, - hold: false, - callIdsToCoach: new List { "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85" } - ); + ApiResponse response = instance.GetConferenceMemberWithHttpInfo(accountId, conferenceId, callId); - var apiResponse = new ApiResponse(HttpStatusCode.OK, conferenceMember); - mockClient.Setup(x => x.Get("/accounts/{accountId}/conferences/{conferenceId}/members/{memberId}",It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.GetConferenceMemberWithHttpInfo(accountId, conferenceId, memberId); - - Assert.IsType>(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.Equal(47, response.Data.CallId.Length); + Assert.Equal(50, response.Data.ConferenceId.Length); + Assert.IsType(response.Data.MemberUrl); + Assert.IsType(response.Data.Mute); + Assert.IsType(response.Data.Hold); + Assert.IsType>(response.Data.CallIdsToCoach); } /// @@ -136,29 +115,21 @@ public void GetConferenceMemberTest() [Fact] public void GetConferenceRecordingTest() { - string accountId = "9900000"; - string conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - ConferenceRecordingMetadata conferenceRecordingMetadata = new ConferenceRecordingMetadata( - accountId: "920012", - conferenceId: "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9", - name: "my-conference-name", - recordingId: "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", - duration: "PT13.67S", - channels: 1, - startTime: new DateTime(2022, 06, 17, 22, 20, 00), - endTime: new DateTime(2022, 06, 17, 22, 20, 00), - fileFormat: FileFormatEnum.Wav, - status: "complete", - mediaUrl:"https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/recordings/r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833/media" - ); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, conferenceRecordingMetadata); - mockClient.Setup(x => x.Get("/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}",It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.GetConferenceRecordingWithHttpInfo(accountId, conferenceId, recordingId); + ApiResponse response = instance.GetConferenceRecordingWithHttpInfo(accountId, conferenceId, recordingId); - Assert.IsType>(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.Equal(7, response.Data.AccountId.Length); + Assert.Equal(50, response.Data.ConferenceId.Length); + Assert.IsType(response.Data.Name); + Assert.Equal(47, response.Data.RecordingId.Length); + Assert.IsType(response.Data.Duration); + Assert.IsType(response.Data.Channels); + Assert.IsType(response.Data.StartTime); + Assert.IsType(response.Data.EndTime); + Assert.IsType(response.Data.FileFormat); + Assert.IsType(response.Data.Status); + Assert.IsType(response.Data.MediaUrl); } /// @@ -167,28 +138,21 @@ public void GetConferenceRecordingTest() [Fact] public void ListConferenceRecordingsTest() { - string accountId = "9900000"; - string conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; - ConferenceRecordingMetadata conferenceRecordingMetadata = new ConferenceRecordingMetadata( - accountId: "920012", - conferenceId: "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9", - name: "my-conference-name", - recordingId: "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", - duration: "PT13.67S", - channels: 1, - startTime: new DateTime(2022, 06, 17, 22, 20, 00), - endTime: new DateTime(2022, 06, 17, 22, 20, 00), - fileFormat: FileFormatEnum.Wav, - status: "complete", - mediaUrl:"https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/recordings/r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833/media" - ); - - var apiResponse = new ApiResponse>(HttpStatusCode.OK, new List() { conferenceRecordingMetadata }); - mockClient.Setup(x => x.Get>("/accounts/{accountId}/conferences/{conferenceId}/recordings",It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.ListConferenceRecordingsWithHttpInfo(accountId, conferenceId); + ApiResponse> response = instance.ListConferenceRecordingsWithHttpInfo(accountId, conferenceId); - Assert.IsType>>(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data[0]); + Assert.Equal(7, response.Data[0].AccountId.Length); + Assert.Equal(50, response.Data[0].ConferenceId.Length); + Assert.IsType(response.Data[0].Name); + Assert.Equal(47, response.Data[0].RecordingId.Length); + Assert.IsType(response.Data[0].Duration); + Assert.IsType(response.Data[0].Channels); + Assert.IsType(response.Data[0].StartTime); + Assert.IsType(response.Data[0].EndTime); + Assert.IsType(response.Data[0].FileFormat); + Assert.IsType(response.Data[0].Status); + Assert.IsType(response.Data[0].MediaUrl); } /// @@ -197,27 +161,17 @@ public void ListConferenceRecordingsTest() [Fact] public void ListConferencesTest() { - string accountId = "9900000"; - string name = "my-custom-name"; - string minCreatedTime = "2022-06-21T19:13:21Z"; - string maxCreatedTime = "2022-06-21T19:13:21Z"; - int? pageSize = 500; - var conference = new Conference( - id: "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9", - name: "my-conference-name", - createdTime: new DateTime(2022, 06, 17, 22, 20, 00), - completedTime: new DateTime(2022, 06, 17, 22, 20, 00), - conferenceEventUrl: "https://myServer.example/bandwidth/webhooks/conferenceEvent", - conferenceEventMethod: CallbackMethodEnum.POST, - tag: "my custom tag" - ); + ApiResponse> response = instance.ListConferencesWithHttpInfo(accountId, conferenceId); - var apiResponse = new ApiResponse>(HttpStatusCode.OK, new List() { conference }); - mockClient.Setup(x => x.Get>("/accounts/{accountId}/conferences",It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.ListConferencesWithHttpInfo(accountId, name, minCreatedTime, maxCreatedTime, pageSize); - - Assert.IsType>>(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data[0]); + Assert.Equal(50, response.Data[0].Id.Length); + Assert.IsType(response.Data[0].Name); + Assert.IsType(response.Data[0].CreatedTime); + Assert.IsType(response.Data[0].CompletedTime); + Assert.IsType(response.Data[0].ConferenceEventUrl); + Assert.IsType(response.Data[0].ConferenceEventMethod); + Assert.IsType(response.Data[0].Tag); } /// @@ -226,35 +180,21 @@ public void ListConferencesTest() [Fact] public void UpdateConferenceTest() { - string accountId = "9900000"; - string conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; - var conference = new Conference( - id: "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9", - name: "my-conference-name", - createdTime: new DateTime(2022, 06, 17, 22, 20, 00), - completedTime: new DateTime(2022, 06, 17, 22, 20, 00), - conferenceEventUrl: "https://myServer.example/bandwidth/webhooks/conferenceEvent", - conferenceEventMethod: CallbackMethodEnum.POST, - tag: "my custom tag" - ); - UpdateConference updateConference = new UpdateConference( - status: ConferenceStateEnum.Completed, - redirectUrl: "https://myServer.example/bandwidth/webhooks/conferenceRedirect", + UpdateConference conference = new( + status: ConferenceStateEnum.Active, + redirectUrl: callbackUrl, redirectMethod: RedirectMethodEnum.POST, username: "username", password: "password", - redirectFallbackUrl: "https://myFallbackServer.example/bandwidth/webhooks/conferenceRedirect", + redirectFallbackUrl: callbackUrl, redirectFallbackMethod: RedirectMethodEnum.POST, - fallbackUsername: "fallbackUsername", - fallbackPassword: "fallbackPassword" + fallbackUsername: "username", + fallbackPassword: "password" ); - var apiResponse = new ApiResponse(HttpStatusCode.OK, conference); - mockClient.Setup(x => x.Post("/accounts/{accountId}/conferences/{conferenceId}",It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.UpdateConferenceWithHttpInfo(accountId, conferenceId, updateConference); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + ApiResponse response = instance.UpdateConferenceWithHttpInfo(accountId, conferenceId, conference); + + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } /// @@ -263,26 +203,11 @@ public void UpdateConferenceTest() [Fact] public void UpdateConferenceBxmlTest() { - string accountId = "9900000"; - string conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; - string body = " "; - var conference = new Conference( - id: "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9", - name: "my-conference-name", - createdTime: new DateTime(2022, 06, 17, 22, 20, 00), - completedTime: new DateTime(2022, 06, 17, 22, 20, 00), - conferenceEventUrl: "https://myServer.example/bandwidth/webhooks/conferenceEvent", - conferenceEventMethod: CallbackMethodEnum.POST, - tag: "my custom tag" - ); + string updateConferenceBxml = ""; + ApiResponse response = instance.UpdateConferenceBxmlWithHttpInfo(accountId, conferenceId, updateConferenceBxml); - var apiResponse = new ApiResponse(HttpStatusCode.OK, conference); - mockClient.Setup(x => x.Put("/accounts/{accountId}/conferences/{conferenceId}/bxml",It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.UpdateConferenceBxmlWithHttpInfo(accountId, conferenceId, body); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } /// @@ -291,28 +216,15 @@ public void UpdateConferenceBxmlTest() [Fact] public void UpdateConferenceMemberTest() { - string accountId = "9900000"; - string conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; - string memberId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - UpdateConferenceMember updateConferenceMember = new UpdateConferenceMember( - mute: false, - hold: false, - callIdsToCoach: new List { "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85" } - ); - ConferenceMember conferenceMember = new ConferenceMember( - callId: "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", - conferenceId: "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9", - mute: false, - hold: false, - callIdsToCoach: new List { "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85" } + UpdateConferenceMember conferenceMember = new( + mute: true, + hold: true, + callIdsToCoach: new List() ); - var apiResponse = new ApiResponse(HttpStatusCode.OK, conferenceMember); - mockClient.Setup(x => x.Put("/accounts/{accountId}/conferences/{conferenceId}/members/{memberId}",It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.UpdateConferenceMemberWithHttpInfo(accountId, conferenceId, memberId, updateConferenceMember); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + ApiResponse response = instance.UpdateConferenceMemberWithHttpInfo(accountId, conferenceId, callId, conferenceMember); + + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/EndpointsApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/EndpointsApiTests.cs index 9a65fd59..d64cd69c 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/EndpointsApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/EndpointsApiTests.cs @@ -9,41 +9,37 @@ */ using System; -using System.IO; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using RestSharp; +using System.Net; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; using Bandwidth.Standard.Model; -using Moq; -using System.Net; namespace Bandwidth.Standard.Test.Unit.Api { /// - /// Class for testing EndpointsApi + /// EndpointsApi Unit Tests /// public class EndpointsApiTests : IDisposable { - private EndpointsApi instance; - private Mock mockClient; - private Mock mockAsynchronousClient; - private Configuration fakeConfiguration; + private readonly EndpointsApi instance; + + private readonly string accountId = Environment.GetEnvironmentVariable("BW_ACCOUNT_ID"); + + private readonly string endpointId = "test-endpoint-id"; public EndpointsApiTests() { - mockClient = new Mock(); - mockAsynchronousClient = new Mock(); - fakeConfiguration = new Configuration(); - fakeConfiguration.BasePath = "https://voice.bandwidth.com/api/v2"; - fakeConfiguration.Username = "username"; - fakeConfiguration.Password = "password"; - instance = new EndpointsApi(mockClient.Object, mockAsynchronousClient.Object, fakeConfiguration); + Configuration configuration = new() + { + BasePath = "http://127.0.0.1:4010", + IgnoreOperationServers = true, + OAuthClientId = Environment.GetEnvironmentVariable("BW_CLIENT_ID"), + OAuthClientSecret = Environment.GetEnvironmentVariable("BW_CLIENT_SECRET") + }; + instance = new EndpointsApi(configuration); } public void Dispose() @@ -66,108 +62,37 @@ public void InstanceTest() [Fact] public void CreateEndpointTest() { - string accountId = "9900000"; - DateTime creationTime = new DateTime(2021, 1, 1, 0, 0, 0, DateTimeKind.Utc); - DateTime expirationTime = new DateTime(2021, 1, 2, 0, 0, 0, DateTimeKind.Utc); - - CreateWebRtcConnectionRequest webRtcRequest = new CreateWebRtcConnectionRequest( - type: EndpointTypeEnum.WEBRTC, - direction: EndpointDirectionEnum.OUTBOUND, - tag: "test-endpoint" - ); - CreateEndpointRequest createEndpointRequest = new CreateEndpointRequest(webRtcRequest); - - var link = new BrtcLink(rel: "self", href: "/accounts/9900000/endpoints/e-15ac29a2"); - - CreateEndpointResponseData responseData = new CreateEndpointResponseData( - endpointId: "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", + CreateWebRtcConnectionRequest webRtcRequest = new( type: EndpointTypeEnum.WEBRTC, - status: EndpointStatusEnum.CONNECTED, - creationTimestamp: creationTime, - expirationTimestamp: expirationTime, - tag: "test-endpoint", - token: "test-token-abc123" + direction: EndpointDirectionEnum.BIDIRECTIONAL ); - CreateEndpointResponse endpointResponse = new CreateEndpointResponse( - links: new List { link }, - data: responseData, - errors: new List() - ); - - var apiResponse = new ApiResponse(HttpStatusCode.Created, endpointResponse); - mockClient.Setup(x => x.Post("/accounts/{accountId}/endpoints", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.CreateEndpointWithHttpInfo(accountId, createEndpointRequest); + ApiResponse response = instance.CreateEndpointWithHttpInfo(accountId, new CreateEndpointRequest(webRtcRequest)); - Assert.IsType>(response); Assert.Equal(HttpStatusCode.Created, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType>(response.Data.Links); + Assert.IsType(response.Data.Data); + Assert.IsType(response.Data.Data.EndpointId); + Assert.IsType(response.Data.Data.Token); + Assert.IsType(response.Data.Data.Type); + Assert.IsType(response.Data.Data.Status); + Assert.IsType(response.Data.Data.CreationTimestamp); + Assert.IsType(response.Data.Data.ExpirationTimestamp); + Assert.IsType(response.Data.Data.Tag); + Assert.IsType>(response.Data.Data.Devices); + Assert.IsType>(response.Data.Errors); } /// - /// Test failed CreateEndpoint Request - /// - [Fact] - public void CreateEndpointBadRequest() - { - string accountId = "9900000"; - CreateWebRtcConnectionRequest webRtcRequest = new CreateWebRtcConnectionRequest( - type: EndpointTypeEnum.WEBRTC, - direction: EndpointDirectionEnum.OUTBOUND - ); - CreateEndpointRequest createEndpointRequest = new CreateEndpointRequest(webRtcRequest); - - var apiResponse = new ApiResponse(HttpStatusCode.BadRequest, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/endpoints", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.CreateEndpoint(accountId, createEndpointRequest)); - - Assert.Equal("Error calling CreateEndpoint: ", Exception.Message); - Assert.Equal(400, Exception.ErrorCode); - } - - /// - /// Test unauthorized CreateEndpoint Request - /// - [Fact] - public void CreateEndpointUnauthorizedRequest() - { - string accountId = "9900000"; - CreateWebRtcConnectionRequest webRtcRequest = new CreateWebRtcConnectionRequest( - type: EndpointTypeEnum.WEBRTC, - direction: EndpointDirectionEnum.OUTBOUND - ); - CreateEndpointRequest createEndpointRequest = new CreateEndpointRequest(webRtcRequest); - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/endpoints", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.CreateEndpoint(accountId, createEndpointRequest)); - - Assert.Equal("Error calling CreateEndpoint: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden CreateEndpoint Request + /// Test DeleteEndpoint /// [Fact] - public void CreateEndpointForbiddenRequest() + public void DeleteEndpointTest() { - string accountId = "9900000"; - CreateWebRtcConnectionRequest webRtcRequest = new CreateWebRtcConnectionRequest( - type: EndpointTypeEnum.WEBRTC, - direction: EndpointDirectionEnum.OUTBOUND - ); - CreateEndpointRequest createEndpointRequest = new CreateEndpointRequest(webRtcRequest); - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; + ApiResponse response = instance.DeleteEndpointWithHttpInfo(accountId, endpointId); - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/endpoints", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.CreateEndpoint(accountId, createEndpointRequest)); - - Assert.Equal("Error calling CreateEndpoint: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } /// @@ -176,81 +101,20 @@ public void CreateEndpointForbiddenRequest() [Fact] public void GetEndpointTest() { - string accountId = "9900000"; - string endpointId = "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; + ApiResponse response = instance.GetEndpointWithHttpInfo(accountId, endpointId); - var endpointResponse = new EndpointResponse( - links: new List(), - data: new Endpoint( - endpointId: endpointId, - type: EndpointTypeEnum.WEBRTC, - status: EndpointStatusEnum.CONNECTED, - creationTimestamp: new DateTime(2021, 1, 1, 0, 0, 0, DateTimeKind.Utc), - expirationTimestamp: new DateTime(2021, 1, 2, 0, 0, 0, DateTimeKind.Utc) - ), - errors: new List() - ); - var apiResponse = new ApiResponse(HttpStatusCode.OK, endpointResponse); - mockClient.Setup(x => x.Get("/accounts/{accountId}/endpoints/{endpointId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.GetEndpointWithHttpInfo(accountId, endpointId); - - Assert.IsType>(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); - } - - /// - /// Test unauthorized GetEndpoint Request - /// - [Fact] - public void GetEndpointUnauthorizedRequest() - { - string accountId = "9900000"; - string endpointId = "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/endpoints/{endpointId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GetEndpoint(accountId, endpointId)); - - Assert.Equal("Error calling GetEndpoint: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden GetEndpoint Request - /// - [Fact] - public void GetEndpointForbiddenRequest() - { - string accountId = "9900000"; - string endpointId = "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/endpoints/{endpointId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GetEndpoint(accountId, endpointId)); - - Assert.Equal("Error calling GetEndpoint: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); - } - - /// - /// Test not found GetEndpoint Request - /// - [Fact] - public void GetEndpointNotFoundRequest() - { - string accountId = "9900000"; - string endpointId = "not an endpoint id"; - - var apiResponse = new ApiResponse(HttpStatusCode.NotFound, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/endpoints/{endpointId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GetEndpoint(accountId, endpointId)); - - Assert.Equal("Error calling GetEndpoint: ", Exception.Message); - Assert.Equal(404, Exception.ErrorCode); + Assert.IsType(response.Data); + Assert.IsType>(response.Data.Links); + Assert.IsType(response.Data.Data); + Assert.IsType(response.Data.Data.EndpointId); + Assert.IsType(response.Data.Data.Type); + Assert.IsType(response.Data.Data.Status); + Assert.IsType(response.Data.Data.CreationTimestamp); + Assert.IsType(response.Data.Data.ExpirationTimestamp); + Assert.IsType(response.Data.Data.Tag); + Assert.IsType>(response.Data.Data.Devices); + Assert.IsType>(response.Data.Errors); } /// @@ -259,127 +123,21 @@ public void GetEndpointNotFoundRequest() [Fact] public void ListEndpointsTest() { - string accountId = "9900000"; - - var listResponse = new ListEndpointsResponse( - links: new List(), - data: new List(), - errors: new List() - ); - var apiResponse = new ApiResponse(HttpStatusCode.OK, listResponse); - mockClient.Setup(x => x.Get("/accounts/{accountId}/endpoints", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.ListEndpointsWithHttpInfo(accountId); + ApiResponse response = instance.ListEndpointsWithHttpInfo(accountId); - Assert.IsType>(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); - } - - /// - /// Test unauthorized ListEndpoints Request - /// - [Fact] - public void ListEndpointsUnauthorizedRequest() - { - string accountId = "9900000"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/endpoints", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.ListEndpoints(accountId)); - - Assert.Equal("Error calling ListEndpoints: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden ListEndpoints Request - /// - [Fact] - public void ListEndpointsForbiddenRequest() - { - string accountId = "9900000"; - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/endpoints", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.ListEndpoints(accountId)); - - Assert.Equal("Error calling ListEndpoints: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); - } - - /// - /// Test DeleteEndpoint - /// - [Fact] - public void DeleteEndpointTest() - { - string accountId = "9900000"; - string endpointId = "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - - var apiResponse = new ApiResponse(HttpStatusCode.NoContent, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/endpoints/{endpointId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.DeleteEndpointWithHttpInfo(accountId, endpointId); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); - } - - /// - /// Test unauthorized DeleteEndpoint Request - /// - [Fact] - public void DeleteEndpointUnauthorizedRequest() - { - string accountId = "9900000"; - string endpointId = "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/endpoints/{endpointId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.DeleteEndpointWithHttpInfo(accountId, endpointId)); - - Assert.Equal("Error calling DeleteEndpoint: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden DeleteEndpoint Request - /// - [Fact] - public void DeleteEndpointForbiddenRequest() - { - string accountId = "9900000"; - string endpointId = "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/endpoints/{endpointId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.DeleteEndpointWithHttpInfo(accountId, endpointId)); - - Assert.Equal("Error calling DeleteEndpoint: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); - } - - /// - /// Test not found DeleteEndpoint Request - /// - [Fact] - public void DeleteEndpointNotFoundRequest() - { - string accountId = "9900000"; - string endpointId = "not an endpoint id"; - - var apiResponse = new ApiResponse(HttpStatusCode.NotFound, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/endpoints/{endpointId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.DeleteEndpointWithHttpInfo(accountId, endpointId)); - - Assert.Equal("Error calling DeleteEndpoint: ", Exception.Message); - Assert.Equal(404, Exception.ErrorCode); + Assert.IsType(response.Data); + Assert.IsType>(response.Data.Links); + Assert.IsType>(response.Data.Data); + Assert.IsType(response.Data.Data[0]); + Assert.IsType(response.Data.Data[0].EndpointId); + Assert.IsType(response.Data.Data[0].Type); + Assert.IsType(response.Data.Data[0].Status); + Assert.IsType(response.Data.Data[0].CreationTimestamp); + Assert.IsType(response.Data.Data[0].ExpirationTimestamp); + Assert.IsType(response.Data.Data[0].Tag); + Assert.IsType(response.Data.Page); + Assert.IsType>(response.Data.Errors); } /// @@ -388,74 +146,11 @@ public void DeleteEndpointNotFoundRequest() [Fact] public void UpdateEndpointBxmlTest() { - string accountId = "9900000"; - string endpointId = "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string bxml = "Hello World"; + string body = "Hello"; - var apiResponse = new ApiResponse(HttpStatusCode.NoContent, null); - mockClient.Setup(x => x.Put("/accounts/{accountId}/endpoints/{endpointId}/bxml", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.UpdateEndpointBxmlWithHttpInfo(accountId, endpointId, bxml); + ApiResponse response = instance.UpdateEndpointBxmlWithHttpInfo(accountId, endpointId, body); - Assert.IsType>(response); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } - - /// - /// Test unauthorized UpdateEndpointBxml Request - /// - [Fact] - public void UpdateEndpointBxmlUnauthorizedRequest() - { - string accountId = "9900000"; - string endpointId = "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string bxml = "Hello World"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Put("/accounts/{accountId}/endpoints/{endpointId}/bxml", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.UpdateEndpointBxmlWithHttpInfo(accountId, endpointId, bxml)); - - Assert.Equal("Error calling UpdateEndpointBxml: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden UpdateEndpointBxml Request - /// - [Fact] - public void UpdateEndpointBxmlForbiddenRequest() - { - string accountId = "9900000"; - string endpointId = "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string bxml = "Hello World"; - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Put("/accounts/{accountId}/endpoints/{endpointId}/bxml", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.UpdateEndpointBxmlWithHttpInfo(accountId, endpointId, bxml)); - - Assert.Equal("Error calling UpdateEndpointBxml: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); - } - - /// - /// Test not found UpdateEndpointBxml Request - /// - [Fact] - public void UpdateEndpointBxmlNotFoundRequest() - { - string accountId = "9900000"; - string endpointId = "not an endpoint id"; - string bxml = "Hello World"; - - var apiResponse = new ApiResponse(HttpStatusCode.NotFound, null); - mockClient.Setup(x => x.Put("/accounts/{accountId}/endpoints/{endpointId}/bxml", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.UpdateEndpointBxmlWithHttpInfo(accountId, endpointId, bxml)); - - Assert.Equal("Error calling UpdateEndpointBxml: ", Exception.Message); - Assert.Equal(404, Exception.ErrorCode); - } } } From 29cfd02261c381f6417c38ca61d8bb45ea25110b Mon Sep 17 00:00:00 2001 From: ckoegel Date: Mon, 6 Jul 2026 15:33:27 -0400 Subject: [PATCH 3/7] regenerate with templates --- .../Unit/Api/MFAApiTests.cs | 183 +----- .../Unit/Api/MediaApiTests.cs | 94 +-- .../Unit/Api/MessagesApiTests.cs | 278 ++------ .../Unit/Api/MultiChannelApiTests.cs | 2 +- .../Unit/Api/PhoneNumberLookupApiTests.cs | 2 +- .../Unit/Api/RecordingsApiTests.cs | 606 ++---------------- .../Unit/Api/StatisticsApiTests.cs | 38 +- .../Unit/Api/TollFreeVerificationApiTests.cs | 77 +-- .../Unit/Api/TranscriptionsApiTests.cs | 78 +-- 9 files changed, 237 insertions(+), 1121 deletions(-) diff --git a/src/Bandwidth.Standard.Test/Unit/Api/MFAApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/MFAApiTests.cs index ce133409..2e56801b 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/MFAApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/MFAApiTests.cs @@ -9,35 +9,35 @@ */ using System; +using System.IO; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using RestSharp; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -using Bandwidth.Standard.Model; -using Moq; -using System.Net; +// uncomment below to import models +//using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Unit.Api +namespace Bandwidth.Standard.Test.Api { /// /// Class for testing MFAApi /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the API endpoint. + /// public class MFAApiTests : IDisposable { private MFAApi instance; - private Mock mockClient; - private Mock mockAsynchronousClient; - private Configuration fakeConfiguration; public MFAApiTests() { - mockClient = new Mock(); - mockAsynchronousClient = new Mock(); - fakeConfiguration = new Configuration(); - fakeConfiguration.BasePath = "https://mfa.bandwidth.com/api/v1"; - fakeConfiguration.Username = "username"; - fakeConfiguration.Password = "password"; - instance = new MFAApi(mockClient.Object, mockAsynchronousClient.Object, fakeConfiguration); + instance = new MFAApi(); } public void Dispose() @@ -51,7 +51,8 @@ public void Dispose() [Fact] public void InstanceTest() { - Assert.IsType(instance); + // TODO uncomment below to test 'IsType' MFAApi + //Assert.IsType(instance); } /// @@ -60,15 +61,11 @@ public void InstanceTest() [Fact] public void GenerateMessagingCodeTest() { - string accountId = "9900000"; - CodeRequest codeRequest = new CodeRequest("+19195551234", "+19195554321", "66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1", "2FA", "Your temporary {NAME} {SCOPE} code is {CODE}", 6); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, new MessagingCodeResponse("123-456-abcd")); - mockClient.Setup(x => x.Post("/accounts/{accountId}/code/messaging", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.GenerateMessagingCodeWithHttpInfo(accountId, codeRequest); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //CodeRequest codeRequest = null; + //var response = instance.GenerateMessagingCode(accountId, codeRequest); + //Assert.IsType(response); } /// @@ -77,15 +74,11 @@ public void GenerateMessagingCodeTest() [Fact] public void GenerateVoiceCodeTest() { - string accountId = "9900000"; - CodeRequest codeRequest = new CodeRequest("+19195551234", "+19195554321", "66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1", "2FA", "Your temporary {NAME} {SCOPE} code is {CODE}", 6); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, new VoiceCodeResponse("c-1234")); - mockClient.Setup(x => x.Post("/accounts/{accountId}/code/voice", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.GenerateVoiceCodeWithHttpInfo(accountId, codeRequest); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //CodeRequest codeRequest = null; + //var response = instance.GenerateVoiceCode(accountId, codeRequest); + //Assert.IsType(response); } /// @@ -94,125 +87,11 @@ public void GenerateVoiceCodeTest() [Fact] public void VerifyCodeTest() { - string accountId = "9900000"; - VerifyCodeRequest verifyCodeRequest = new VerifyCodeRequest("+19195551234", "2FA", 3, "123456"); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, new VerifyCodeResponse(true)); - mockClient.Setup(x => x.Post("/accounts/{accountId}/code/verify", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.VerifyCodeWithHttpInfo(accountId, verifyCodeRequest); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - } - - /// - /// Test failed Generate Messaging Code Request - /// - [Fact] - public void GenerateMessagingCodeBadRequest() - { - string accountId = "9900000"; - CodeRequest codeRequest = new CodeRequest("+19195551234", "+19195554321", "not-an-application-id", "2FA", "Your temporary {NAME} {SCOPE} code is {CODE}", 6); - - var apiResponse = new ApiResponse(HttpStatusCode.BadRequest, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/code/messaging", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GenerateMessagingCode(accountId, codeRequest)); - - Assert.Equal("Error calling GenerateMessagingCode: ", Exception.Message); - Assert.Equal(400, Exception.ErrorCode); - } - - /// - /// Test failed Generate Voice Code Request - /// - [Fact] - public void GenerateVoiceCodeBadRequest() - { - string accountId = "9900000"; - CodeRequest codeRequest = new CodeRequest("+19195551234", "+19195554321", "not-an-application-id", "2FA", "Your temporary {NAME} {SCOPE} code is {CODE}", 6); - - var apiResponse = new ApiResponse(HttpStatusCode.BadRequest, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/code/voice", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GenerateVoiceCode(accountId, codeRequest)); - - Assert.Equal("Error calling GenerateVoiceCode: ", Exception.Message); - Assert.Equal(400, Exception.ErrorCode); - } - - /// - /// Test unauthorized Generate Messaging Code Request - /// - [Fact] - public void GenerateMessagingCodeUnauthorizedRequest() - { - string accountId = "9900000"; - CodeRequest codeRequest = new CodeRequest("+19195551234", "+19195554321", "123-456-abcd", "2FA", "Your temporary {NAME} {SCOPE} code is {CODE}", 6); - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, new MessagingCodeResponse("Unauthorized")); - mockClient.Setup(x => x.Post("/accounts/{accountId}/code/messaging", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GenerateMessagingCode(accountId, codeRequest)); - - Assert.Equal("Error calling GenerateMessagingCode: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test unauthorized Generate Voice Code Request - /// - [Fact] - public void GenerateVoiceCodeUnauthorizedRequest() - { - string accountId = "9900000"; - CodeRequest codeRequest = new CodeRequest("+19195551234", "+19195554321", "123-456-abcd", "2FA", "Your temporary {NAME} {SCOPE} code is {CODE}", 6); - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, new VoiceCodeResponse("Unauthorized")); - mockClient.Setup(x => x.Post("/accounts/{accountId}/code/voice", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GenerateVoiceCode(accountId, codeRequest)); - - Assert.Equal("Error calling GenerateVoiceCode: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden Generate Messaging Code Request - /// - [Fact] - public void GenerateMessagingCodeForbiddenRequest() - { - string accountId = "9900000"; - CodeRequest codeRequest = new CodeRequest("+19195551234", "+19195554321", "123-456-abcd", "2FA", "Your temporary {NAME} {SCOPE} code is {CODE}", 6); - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, new MessagingCodeResponse("Missing Authentication Token")); - mockClient.Setup(x => x.Post("/accounts/{accountId}/code/messaging", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GenerateMessagingCode(accountId, codeRequest)); - - Assert.Equal("Error calling GenerateMessagingCode: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); - } - - /// - /// Test forbidden Generate Voice Code Request - /// - [Fact] - public void GenerateVoiceCodeForbiddenRequest() - { - string accountId = "9900000"; - CodeRequest codeRequest = new CodeRequest("+19195551234", "+19195554321", "123-456-abcd", "2FA", "Your temporary {NAME} {SCOPE} code is {CODE}", 6); - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, new VoiceCodeResponse("Missing Authentication Token")); - mockClient.Setup(x => x.Post("/accounts/{accountId}/code/voice", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GenerateVoiceCode(accountId, codeRequest)); - - Assert.Equal("Error calling GenerateVoiceCode: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //VerifyCodeRequest verifyCodeRequest = null; + //var response = instance.VerifyCode(accountId, verifyCodeRequest); + //Assert.IsType(response); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/MediaApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/MediaApiTests.cs index 38959673..b669f442 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/MediaApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/MediaApiTests.cs @@ -19,31 +19,25 @@ using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -using Bandwidth.Standard.Model; -using Moq; -using System.Net; +// uncomment below to import models +//using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Unit.Api +namespace Bandwidth.Standard.Test.Api { /// /// Class for testing MediaApi /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the API endpoint. + /// public class MediaApiTests : IDisposable { private MediaApi instance; - private Mock mockClient; - private Mock mockAsynchronousClient; - private Configuration fakeConfiguration; public MediaApiTests() { - mockClient = new Mock(); - mockAsynchronousClient = new Mock(); - fakeConfiguration = new Configuration(); - fakeConfiguration.BasePath = "https://messaging.bandwidth.com/api/v2"; - fakeConfiguration.Username = "username"; - fakeConfiguration.Password = "password"; - instance = new MediaApi(mockClient.Object, mockAsynchronousClient.Object, fakeConfiguration); + instance = new MediaApi(); } public void Dispose() @@ -57,7 +51,8 @@ public void Dispose() [Fact] public void InstanceTest() { - Assert.IsType(instance); + // TODO uncomment below to test 'IsType' MediaApi + //Assert.IsType(instance); } /// @@ -66,15 +61,10 @@ public void InstanceTest() [Fact] public void DeleteMediaTest() { - string accountId = "9900000"; - string mediaId = "14762070468292kw2fuqty55yp2b2/0/bw.png"; - - var apiResponse = new ApiResponse(HttpStatusCode.NoContent, null); - mockClient.Setup(x => x.Delete("/users/{accountId}/media/{mediaId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.DeleteMediaWithHttpInfo(accountId, mediaId); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string mediaId = null; + //instance.DeleteMedia(accountId, mediaId); } /// @@ -83,20 +73,11 @@ public void DeleteMediaTest() [Fact] public void GetMediaTest() { - string accountId = "9900000"; - string mediaId = "14762070468292kw2fuqty55yp2b2/0/bw.png"; - string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; - string relativePath = "../../../Fixtures/csharp_cat.jpeg"; - string filePath = Path.Combine(baseDirectory, relativePath); - System.IO.Stream body = new System.IO.FileStream(filePath, FileMode.Open); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, body); - mockClient.Setup(x => x.Get("/users/{accountId}/media/{mediaId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.GetMediaWithHttpInfo(accountId, mediaId); - - Assert.IsAssignableFrom>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - body.Close(); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string mediaId = null; + //var response = instance.GetMedia(accountId, mediaId); + //Assert.IsType(response); } /// @@ -105,16 +86,11 @@ public void GetMediaTest() [Fact] public void ListMediaTest() { - string accountId = "9900000"; - Media media = new Media(content: "content", contentLength: 1, mediaName: "test"); - List mediaList = new List() { media }; - - var apiResponse = new ApiResponse>(HttpStatusCode.OK, mediaList); - mockClient.Setup(x => x.Get>("/users/{accountId}/media", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.ListMediaWithHttpInfo(accountId); - - Assert.IsType>>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string continuationToken = null; + //var response = instance.ListMedia(accountId, continuationToken); + //Assert.IsType>(response); } /// @@ -123,21 +99,13 @@ public void ListMediaTest() [Fact] public void UploadMediaTest() { - string accountId = "9900000"; - string mediaId = "14762070468292kw2fuqty55yp2b2/0/bw.png"; - string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; - string relativePath = "../../../Fixtures/csharp_cat.jpeg"; - string filePath = Path.Combine(baseDirectory, relativePath); - System.IO.Stream body = new System.IO.FileStream(filePath, FileMode.Open); - string contentType = "image/jpeg"; - - var apiResponse = new ApiResponse(HttpStatusCode.NoContent, null); - mockClient.Setup(x => x.Put("/users/{accountId}/media/{mediaId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.UploadMediaWithHttpInfo(accountId, mediaId, body, contentType); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); - body.Close(); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string mediaId = null; + //System.IO.Stream body = null; + //string contentType = null; + //string cacheControl = null; + //instance.UploadMedia(accountId, mediaId, body, contentType, cacheControl); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/MessagesApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/MessagesApiTests.cs index e94d2031..4cb4e131 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/MessagesApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/MessagesApiTests.cs @@ -19,31 +19,25 @@ using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -using Bandwidth.Standard.Model; -using Moq; -using System.Net; +// uncomment below to import models +//using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Unit.Api +namespace Bandwidth.Standard.Test.Api { /// /// Class for testing MessagesApi /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the API endpoint. + /// public class MessagesApiTests : IDisposable { private MessagesApi instance; - private Mock mockClient; - private Mock mockAsynchronousClient; - private Configuration fakeConfiguration; public MessagesApiTests() { - mockClient = new Mock(); - mockAsynchronousClient = new Mock(); - fakeConfiguration = new Configuration(); - fakeConfiguration.BasePath = "https://messaging.bandwidth.com/api/v2"; - fakeConfiguration.Username = "username"; - fakeConfiguration.Password = "password"; - instance = new MessagesApi(mockClient.Object, mockAsynchronousClient.Object, fakeConfiguration); + instance = new MessagesApi(); } public void Dispose() @@ -57,7 +51,8 @@ public void Dispose() [Fact] public void InstanceTest() { - Assert.IsType(instance); + // TODO uncomment below to test 'IsType' MessagesApi + //Assert.IsType(instance); } /// @@ -66,94 +61,11 @@ public void InstanceTest() [Fact] public void CreateMessageTest() { - string accountId = "9900000"; - MessageRequest messageRequest = new MessageRequest( - applicationId: "93de2206-9669-4e07-948d-329f4b722ee2", - to: new List { "+15554443333", "+15552223333" }, - from: "+15551113333", - text: "Hello World", - media: new List { "https://dev.bandwidth.com/images/bandwidth-logo.png","https://dev.bandwidth.com/images/github_logo.png" }, - tag: "custom string", - priority: PriorityEnum.Default, - expiration: new DateTime(2020, 1, 1) - ); - Message message = new Message( - id: "1589228074636lm4k2je7j7jklbn2", - owner: "+15554443333", - applicationId: "93de2206-9669-4e07-948d-329f4b722ee2", - time: new DateTime(2020, 1, 1), - segmentCount: 2, - direction: MessageDirectionEnum.Out, - to: new List { "+15554443333", "+15552223333" }, - from: "+15551113333", - media: new List {"https://dev.bandwidth.com/images/bandwidth-logo.png"}, - text: "Hello World", - tag: "custom string", - priority: PriorityEnum.Default, - expiration: new DateTime(2020, 1, 2) - ); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, message); - mockClient.Setup(x => x.Post("/users/{accountId}/messages", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.CreateMessageWithHttpInfo(accountId, messageRequest); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - } - - /// - /// Test failed CreateMessage Request - /// - [Fact] - public void CreateMessageBadRequest() - { - string accountId = "9900000"; - MessageRequest messageRequest = new MessageRequest( - applicationId: "93de2206-9669-4e07-948d-329f4b722ee2", - to: new List { "+15554443333", "+15552223333" }, - from: "+15551113333", - text: "Hello World", - media: new List { "https://dev.bandwidth.com/images/bandwidth-logo.png","https://dev.bandwidth.com/images/github_logo.png" }, - tag: "custom string", - priority: PriorityEnum.Default, - expiration: new DateTime(2020, 1, 1) - ); - messageRequest.ApplicationId = null; // Bad Request - - var apiResponse = new ApiResponse(HttpStatusCode.BadRequest, null); - mockClient.Setup(x => x.Post("/users/{accountId}/messages", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.CreateMessage(accountId, messageRequest)); - - Assert.Equal("Error calling CreateMessage: ", Exception.Message); - Assert.Equal(400, Exception.ErrorCode); - } - - /// - /// Test Unauthorized CreateMessage Request - /// - [Fact] - public void CreateMessageUnauthorizedRequest() - { - string accountId = "9900000"; - MessageRequest messageRequest = new MessageRequest( - applicationId: "93de2206-9669-4e07-948d-329f4b722ee2", - to: new List { "+15554443333", "+15552223333" }, - from: "+15551113333", - text: "Hello World", - media: new List { "https://dev.bandwidth.com/images/bandwidth-logo.png","https://dev.bandwidth.com/images/github_logo.png" }, - tag: "custom string", - priority: PriorityEnum.Default, - expiration: new DateTime(2020, 1, 1) - ); - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Post("/users/{accountId}/messages", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.CreateMessage(accountId, messageRequest)); - - Assert.Equal("Error calling CreateMessage: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //MessageRequest messageRequest = null; + //var response = instance.CreateMessage(accountId, messageRequest); + //Assert.IsType(response); } /// @@ -162,135 +74,37 @@ public void CreateMessageUnauthorizedRequest() [Fact] public void ListMessagesTest() { - string accountId = "9900000"; - MessagesList messagesList = new MessagesList( - totalCount: 1, - messages: new List { new ListMessageItem( - messageId: "1589228074636lm4k2je7j7jklbn2", - accountId: "9900000", - sourceTn: "+15554443333", - destinationTn: "+15554442222", - messageStatus: MessageStatusEnum.RECEIVED, - messageDirection: ListMessageDirectionEnum.OUTBOUND, - messageType: MessageTypeEnum.Sms, - segmentCount: 1, - errorCode: 9902, - receiveTime: new DateTime(2020, 1, 1), - carrierName: "other", - messageSize: 1, - messageLength: 18, - attachmentCount: 0, - recipientCount: 1, - campaignClass: "T", - campaignId: "CJEUMDK", - bwLatency: 10, - callingNumberCountryA3: "callingNumberCountryA3", - calledNumberCountryA3: "calledNumberCountryA3", - product: "product", - location: "location" - )} - ); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, messagesList); - mockClient.Setup(x => x.Get("/users/{accountId}/messages", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.ListMessagesWithHttpInfo( - accountId: accountId, - messageId: "1589228074636lm4k2je7j7jklbn2", - sourceTn: "+15554443333", - destinationTn: "+15554442222", - messageStatus: MessageStatusEnum.RECEIVED, - messageDirection: ListMessageDirectionEnum.OUTBOUND, - carrierName: "other", - messageType: MessageTypeEnum.Sms, - errorCode: 9902, - fromDateTime: "2022-09-14T18:20:16.000Z", - toDateTime: "2022-09-14T18:20:16.000Z", - campaignId: "CJEUMDK", - fromBwLatency: 10, - bwQueued: true, - product: ProductTypeEnum.LOCALA2P, - location: "location", - carrierQueued: true, - fromCarrierLatency: 10, - callingNumberCountryA3: "callingNumberCountryA3", - calledNumberCountryA3: "calledNumberCountryA3", - fromSegmentCount: 1, - toSegmentCount: 1, - fromMessageSize: 1, - toMessageSize: 1, - sort: "receiveTime", - pageToken: "gdEewhcJLQRB5", - limit: 10, - limitTotalCount: true - ); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - } - - /// - /// Test failed ListMessages Request - /// - [Fact] - public void ListMessagesBadRequest() - { - var apiResponse = new ApiResponse(HttpStatusCode.BadRequest, null); - mockClient.Setup(x => x.Get("/users/{accountId}/messages", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.ListMessagesWithHttpInfo( - accountId: "9900000", - messageId: "1589228074636lm4k2je7j7jklbn2", - sourceTn: "+15554443333", - destinationTn: "+15554443333", - messageStatus: MessageStatusEnum.RECEIVED, - messageDirection: ListMessageDirectionEnum.OUTBOUND, - carrierName: "Verizon", - messageType: MessageTypeEnum.Sms, - errorCode: 9902, - fromDateTime: "2022-09-14T18:20:16.000Z", - toDateTime: "2022-09-14T18:20:16.000Z", - campaignId: "CJEUMDK", - sort: "sourceTn:desc", - pageToken: "gdEewhcJLQRB5", // Bad Token - limit: 10, - limitTotalCount: true - )); - - Assert.Equal("Error calling ListMessages: ", Exception.Message); - Assert.Equal(400, Exception.ErrorCode); - } - - /// - /// Test Unauthorized ListMessages Request - /// - [Fact] - public void ListMessagesUnauthorizedRequest() - { - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Get("/users/{accountId}/messages", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.ListMessagesWithHttpInfo( - accountId: "9900000", - messageId: "1589228074636lm4k2je7j7jklbn2", - sourceTn: "+15554443333", - destinationTn: "+15554443333", - messageStatus: MessageStatusEnum.RECEIVED, - messageDirection: ListMessageDirectionEnum.OUTBOUND, - carrierName: "Verizon", - messageType: MessageTypeEnum.Sms, - errorCode: 9902, - fromDateTime: "2022-09-14T18:20:16.000Z", - toDateTime: "2022-09-14T18:20:16.000Z", - campaignId: "CJEUMDK", - sort: "sourceTn:desc", - pageToken: "gdEewhcJLQRB5", - limit: 10, - limitTotalCount: true - )); - - Assert.Equal("Error calling ListMessages: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string messageId = null; + //string sourceTn = null; + //string destinationTn = null; + //MessageStatusEnum? messageStatus = null; + //ListMessageDirectionEnum? messageDirection = null; + //string carrierName = null; + //MessageTypeEnum? messageType = null; + //int? errorCode = null; + //string fromDateTime = null; + //string toDateTime = null; + //string campaignId = null; + //int? fromBwLatency = null; + //bool? bwQueued = null; + //ProductTypeEnum? product = null; + //string location = null; + //bool? carrierQueued = null; + //int? fromCarrierLatency = null; + //string callingNumberCountryA3 = null; + //string calledNumberCountryA3 = null; + //int? fromSegmentCount = null; + //int? toSegmentCount = null; + //int? fromMessageSize = null; + //int? toMessageSize = null; + //string sort = null; + //string pageToken = null; + //int? limit = null; + //bool? limitTotalCount = null; + //var response = instance.ListMessages(accountId, messageId, sourceTn, destinationTn, messageStatus, messageDirection, carrierName, messageType, errorCode, fromDateTime, toDateTime, campaignId, fromBwLatency, bwQueued, product, location, carrierQueued, fromCarrierLatency, callingNumberCountryA3, calledNumberCountryA3, fromSegmentCount, toSegmentCount, fromMessageSize, toMessageSize, sort, pageToken, limit, limitTotalCount); + //Assert.IsType(response); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/MultiChannelApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/MultiChannelApiTests.cs index aa8fd867..dbdb1fe2 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/MultiChannelApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/MultiChannelApiTests.cs @@ -22,7 +22,7 @@ // uncomment below to import models //using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Unit.Api +namespace Bandwidth.Standard.Test.Api { /// /// Class for testing MultiChannelApi diff --git a/src/Bandwidth.Standard.Test/Unit/Api/PhoneNumberLookupApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/PhoneNumberLookupApiTests.cs index 3f94fe61..a9c77c19 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/PhoneNumberLookupApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/PhoneNumberLookupApiTests.cs @@ -22,7 +22,7 @@ // uncomment below to import models //using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Unit.Api +namespace Bandwidth.Standard.Test.Api { /// /// Class for testing PhoneNumberLookupApi diff --git a/src/Bandwidth.Standard.Test/Unit/Api/RecordingsApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/RecordingsApiTests.cs index c16bbb35..372b7cd2 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/RecordingsApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/RecordingsApiTests.cs @@ -19,31 +19,25 @@ using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -using Bandwidth.Standard.Model; -using Moq; -using System.Net; +// uncomment below to import models +//using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Unit.Api +namespace Bandwidth.Standard.Test.Api { /// /// Class for testing RecordingsApi /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the API endpoint. + /// public class RecordingsApiTests : IDisposable { private RecordingsApi instance; - private Mock mockClient; - private Mock mockAsynchronousClient; - private Configuration fakeConfiguration; public RecordingsApiTests() { - mockClient = new Mock(); - mockAsynchronousClient = new Mock(); - fakeConfiguration = new Configuration(); - fakeConfiguration.BasePath = "https://voice.bandwidth.com/api/v2"; - fakeConfiguration.Username = "username"; - fakeConfiguration.Password = "password"; - instance = new RecordingsApi(mockClient.Object, mockAsynchronousClient.Object, fakeConfiguration); + instance = new RecordingsApi(); } public void Dispose() @@ -57,65 +51,8 @@ public void Dispose() [Fact] public void InstanceTest() { - Assert.IsType(instance); - } - - /// - /// Test DeleteRecordingTranscription - /// - [Fact] - public void DeleteRecordingTranscriptionTest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - - var apiResponse = new ApiResponse(HttpStatusCode.NoContent, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.DeleteRecordingTranscriptionWithHttpInfo(accountId, callId, recordingId); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); - } - - /// - /// Test Unauthorized DeleteRecordingTranscription - /// - [Fact] - public void DeleteRecordingTranscriptionUnauthorizedRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.DeleteRecordingTranscriptionWithHttpInfo(accountId, callId, recordingId)); - - Assert.Equal("Error calling DeleteRecordingTranscription: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test Forbidden DeleteRecordingTranscription - /// - [Fact] - public void DeleteRecordingTranscriptionForbiddenRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - fakeConfiguration.Username = "ForbiddenUsername"; - fakeConfiguration.Password = "ForbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.DeleteRecordingTranscriptionWithHttpInfo(accountId, callId, recordingId)); - - Assert.Equal("Error calling DeleteRecordingTranscription: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); + // TODO uncomment below to test 'IsType' RecordingsApi + //Assert.IsType(instance); } /// @@ -124,57 +61,11 @@ public void DeleteRecordingTranscriptionForbiddenRequest() [Fact] public void DeleteRecordingTest() { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - - var apiResponse = new ApiResponse(HttpStatusCode.NoContent, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.DeleteRecordingWithHttpInfo(accountId, callId, recordingId); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); - } - - /// - /// Test Unauthorized DeleteRecording - /// - [Fact] - public void DeleteRecordingUnauthorizedRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - - ApiException Exception = Assert.Throws(() => instance.DeleteRecordingWithHttpInfo(accountId, callId, recordingId)); - - Assert.Equal("Error calling DeleteRecording: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden DeleteRecording - /// - [Fact] - public void DeleteRecordingForbiddenRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.DeleteRecordingWithHttpInfo(accountId, callId, recordingId)); - - Assert.Equal("Error calling DeleteRecording: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string callId = null; + //string recordingId = null; + //instance.DeleteRecording(accountId, callId, recordingId); } /// @@ -183,56 +74,24 @@ public void DeleteRecordingForbiddenRequest() [Fact] public void DeleteRecordingMediaTest() { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - - var apiResponse = new ApiResponse(HttpStatusCode.NoContent, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.DeleteRecordingMediaWithHttpInfo(accountId, callId, recordingId); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string callId = null; + //string recordingId = null; + //instance.DeleteRecordingMedia(accountId, callId, recordingId); } /// - /// Test Unauthorized DeleteRecordingMedia - /// - [Fact] - public void DeleteRecordingMediaUnauthorizedRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d8"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d8"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.DeleteRecordingMediaWithHttpInfo(accountId, callId, recordingId)); - - Assert.Equal("Error calling DeleteRecordingMedia: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden DeleteRecordingMedia + /// Test DeleteRecordingTranscription /// [Fact] - public void DeleteRecordingMediaForbiddenRequest() + public void DeleteRecordingTranscriptionTest() { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d8"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d8"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.DeleteRecordingMediaWithHttpInfo(accountId, callId, recordingId)); - - Assert.Equal("Error calling DeleteRecordingMedia: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string callId = null; + //string recordingId = null; + //instance.DeleteRecordingTranscription(accountId, callId, recordingId); } /// @@ -241,62 +100,12 @@ public void DeleteRecordingMediaForbiddenRequest() [Fact] public void DownloadCallRecordingTest() { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; - string relativePath = "../../../Fixtures/csharp_test_recording.wav"; - string filePath = Path.Combine(baseDirectory, relativePath); - System.IO.Stream body = new System.IO.FileStream(filePath, FileMode.Open); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, body); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.DownloadCallRecordingWithHttpInfo(accountId, callId, recordingId); - - Assert.IsAssignableFrom>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - body.Close(); - } - - /// - /// Test Unauthorized DownloadCallRecording - /// - [Fact] - public void DownloadCallRecordingUnauthorizedRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b21-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b21-b22865662d85"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.DownloadCallRecordingWithHttpInfo(accountId, callId, recordingId)); - - Assert.Equal("Error calling DownloadCallRecording: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - - /// - /// Test forbidden DownloadCallRecording - /// - [Fact] - public void DownloadCallRecordingForbiddenRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a-b215-b22865662d85"; - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.DownloadCallRecordingWithHttpInfo(accountId, callId, recordingId)); - - Assert.Equal("Error calling DownloadCallRecording: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string callId = null; + //string recordingId = null; + //var response = instance.DownloadCallRecording(accountId, callId, recordingId); + //Assert.IsType(response); } /// @@ -305,99 +114,12 @@ public void DownloadCallRecordingForbiddenRequest() [Fact] public void GetCallRecordingTest() { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - CallRecordingMetadata callRecordingMetadata = new CallRecordingMetadata( - applicationId: "04e88489-df02-4e34-a0ee-27a91849555f", - accountId: "920012", - callId: "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", - parentCallId: "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d", - recordingId: "r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833", - to: "+15555555555", - from: "+15555555555", - transferCallerId: "+15555555555", - transferTo: "+15555555555", - duration: "PT13.67S", - direction: CallDirectionEnum.Inbound, - channels: 1, - startTime: new DateTime(2022, 06, 21, 19, 13, 21, DateTimeKind.Utc), - endTime: new DateTime(2022, 06, 21, 19, 13, 21, DateTimeKind.Utc), - fileFormat: FileFormatEnum.Wav, - status: "completed", - mediaUrl: "https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/recordings/r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833/media", - transcription: new RecordingTranscriptionMetadata( - id: "t-387bd648-18f3-4823-9d16-746bca0003c9", - status: "completed", - completedTime: DateTime.UtcNow, - url: "https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/transcription" - ) - ); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, callRecordingMetadata); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.GetCallRecordingWithHttpInfo(accountId, callId, recordingId); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - } - - /// - /// Test GetCallRecording not Found - /// - [Fact] - public void GetCallRecordingNotFound() - { - string accountId = "9900000"; - string callId = "not a call id"; - string recordingId = "not a recording id"; - - var apiResponse = new ApiResponse(HttpStatusCode.NotFound, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GetCallRecordingWithHttpInfo(accountId, callId, recordingId)); - - Assert.Equal("Error calling GetCallRecording: ", Exception.Message); - Assert.Equal(404, Exception.ErrorCode); - } - - /// - /// Test Unauthorized GetCallRecording - /// - [Fact] - public void GetCallRecordingUnauthorizedRequestTest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GetCallRecordingWithHttpInfo(accountId, callId, recordingId)); - - Assert.Equal("Error calling GetCallRecording: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden GetCallRecording - /// - [Fact] - public void GetCallRecordingForbiddenRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.GetCallRecordingWithHttpInfo(accountId, callId, recordingId)); - - Assert.Equal("Error calling GetCallRecording: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string callId = null; + //string recordingId = null; + //var response = instance.GetCallRecording(accountId, callId, recordingId); + //Assert.IsType(response); } /// @@ -406,18 +128,12 @@ public void GetCallRecordingForbiddenRequest() [Fact] public void GetRecordingTranscriptionTest() { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - Transcription transcription = new Transcription(text: "Nice talking to you, friend!", confidence: .9); - RecordingTranscriptions recordingTranscriptions = new RecordingTranscriptions(transcripts: new List { transcription }); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, recordingTranscriptions); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.GetRecordingTranscriptionWithHttpInfo(accountId, callId, recordingId); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string callId = null; + //string recordingId = null; + //var response = instance.GetRecordingTranscription(accountId, callId, recordingId); + //Assert.IsType(response); } /// @@ -426,135 +142,27 @@ public void GetRecordingTranscriptionTest() [Fact] public void ListAccountCallRecordingsTest() { - string accountId = "9900000"; - CallRecordingMetadata callRecordingMetadata = new CallRecordingMetadata( - applicationId: "04e88489-df02-4e34-a0ee-27a91849555f", - accountId: "920012", - callId: "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", - parentCallId: "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d", - recordingId: "r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833", - to: "+15555555555", - from: "+15555555555", - transferCallerId: "+15555555555", - transferTo: "+15555555555", - duration: "PT13.67S", - direction: CallDirectionEnum.Inbound, - channels: 1, - startTime: new DateTime(2022, 06, 21, 19, 13, 21, DateTimeKind.Utc), - endTime: new DateTime(2022, 06, 21, 19, 13, 21, DateTimeKind.Utc), - fileFormat: FileFormatEnum.Wav, - status: "completed", - mediaUrl: "https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/recordings/r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833/media", - transcription: new RecordingTranscriptionMetadata( - id: "t-387bd648-18f3-4823-9d16-746bca0003c9", - status: "completed", - completedTime: DateTime.UtcNow, - url: "https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/transcription" - ) - ); - - var apiResponse = new ApiResponse>(HttpStatusCode.OK, new List() { callRecordingMetadata }); - mockClient.Setup(x => x.Get>("/accounts/{accountId}/recordings", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.ListAccountCallRecordingsWithHttpInfo( - accountId: accountId, - to: "+19195551234", - from: "+19195554321", - minStartTime: "2022-06-21T19:13:21Z", - maxStartTime: "2022-06-21T19:13:21Z" - ); - - Assert.IsType>>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string to = null; + //string from = null; + //string minStartTime = null; + //string maxStartTime = null; + //var response = instance.ListAccountCallRecordings(accountId, to, from, minStartTime, maxStartTime); + //Assert.IsType>(response); } - /// - /// Test Unauthorized ListAccountCallRecordings - /// - [Fact] - public void ListAccountCallRecordingsUnauthorizedRequestTest() - { - string accountId = "9900000"; - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse>(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Get>("/accounts/{accountId}/recordings", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.ListAccountCallRecordingsWithHttpInfo( - accountId: accountId, - to: "+19195551234", - from: "+19195554321", - minStartTime: "2022-06-21T19:13:21Z", - maxStartTime: "2022-06-21T19:13:21Z" - )); - - Assert.Equal("Error calling ListAccountCallRecordings: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden ListAccountCallRecordings - /// - [Fact] - public void ListAccountCallRecordingsForbiddenRequestTest() - { - string accountId = "9900000"; - - var apiResponse = new ApiResponse>(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Get>("/accounts/{accountId}/recordings", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.ListAccountCallRecordingsWithHttpInfo( - accountId: accountId, - to: "+19195551234", - from: "+19195554321", - minStartTime: "2022-06-21T19:13:21Z", - maxStartTime: "2022-06-21T19:13:21Z" - )); - - Assert.Equal("Error calling ListAccountCallRecordings: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); - } - - /// /// Test ListCallRecordings /// [Fact] public void ListCallRecordingsTest() { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - CallRecordingMetadata callRecordingMetadata = new CallRecordingMetadata( - applicationId: "04e88489-df02-4e34-a0ee-27a91849555f", - accountId: "920012", - callId: "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", - parentCallId: "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d", - recordingId: "r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833", - to: "+15555555555", - from: "+15555555555", - transferCallerId: "+15555555555", - transferTo: "+15555555555", - duration: "PT13.67S", - direction: CallDirectionEnum.Inbound, - channels: 1, - startTime: new DateTime(2022, 06, 21, 19, 13, 21, DateTimeKind.Utc), - endTime: new DateTime(2022, 06, 21, 19, 13, 21, DateTimeKind.Utc), - fileFormat: FileFormatEnum.Wav, - status: "completed", - mediaUrl: "https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/recordings/r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833/media", - transcription: new RecordingTranscriptionMetadata( - id: "t-387bd648-18f3-4823-9d16-746bca0003c9", - status: "completed", - completedTime: DateTime.UtcNow, - url: "https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/transcription" - ) - ); - - var apiResponse = new ApiResponse>(HttpStatusCode.OK, new List() { callRecordingMetadata }); - mockClient.Setup(x => x.Get>("/accounts/{accountId}/calls/{callId}/recordings", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.ListCallRecordingsWithHttpInfo(accountId, callId); - - Assert.IsType>>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string callId = null; + //var response = instance.ListCallRecordings(accountId, callId); + //Assert.IsType>(response); } /// @@ -563,83 +171,12 @@ public void ListCallRecordingsTest() [Fact] public void TranscribeCallRecordingTest() { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - TranscribeRecording transcribeRecording = new TranscribeRecording( - callbackUrl: "https://myServer.example/bandwidth/webhooks/transcriptionAvailable", - callbackMethod: CallbackMethodEnum.POST, - username: "mySecretUsername", - password: "mySecretPassword", - tag: "exampleTag", - callbackTimeout: 15, - detectLanguage: true - ); - - var apiResponse = new ApiResponse(HttpStatusCode.NoContent, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.TranscribeCallRecordingWithHttpInfo(accountId, callId, recordingId, transcribeRecording); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); - } - - /// - /// Test Unauthorized TranscribeCallRecording - /// - [Fact] - public void TranscribeCallRecordingUnauthorizedRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - TranscribeRecording transcribeRecording = new TranscribeRecording( - callbackUrl: "https://myServer.example/bandwidth/webhooks/transcriptionAvailable", - callbackMethod: CallbackMethodEnum.POST, - username: "mySecretUsername", - password: "mySecretPassword", - tag: "exampleTag", - callbackTimeout: 15, - detectLanguage: true - ); - fakeConfiguration.Username = "badUsername"; - fakeConfiguration.Password = "badPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Unauthorized, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.TranscribeCallRecordingWithHttpInfo(accountId, callId, recordingId, transcribeRecording)); - - Assert.Equal("Error calling TranscribeCallRecording: ", Exception.Message); - Assert.Equal(401, Exception.ErrorCode); - } - - /// - /// Test forbidden TranscribeCallRecording - /// - [Fact] - public void TranscribeCallRecordingForbiddenRequest() - { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - string recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - TranscribeRecording transcribeRecording = new TranscribeRecording( - callbackUrl: "https://myServer.example/bandwidth/webhooks/transcriptionAvailable", - callbackMethod: CallbackMethodEnum.POST, - username: "mySecretUsername", - password: "mySecretPassword", - tag: "exampleTag", - callbackTimeout: 15, - detectLanguage: true - ); - fakeConfiguration.Username = "forbiddenUsername"; - fakeConfiguration.Password = "forbiddenPassword"; - - var apiResponse = new ApiResponse(HttpStatusCode.Forbidden, null); - mockClient.Setup(x => x.Post("/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - ApiException Exception = Assert.Throws(() => instance.TranscribeCallRecordingWithHttpInfo(accountId, callId, recordingId, transcribeRecording)); - - Assert.Equal("Error calling TranscribeCallRecording: ", Exception.Message); - Assert.Equal(403, Exception.ErrorCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string callId = null; + //string recordingId = null; + //TranscribeRecording transcribeRecording = null; + //instance.TranscribeCallRecording(accountId, callId, recordingId, transcribeRecording); } /// @@ -648,16 +185,11 @@ public void TranscribeCallRecordingForbiddenRequest() [Fact] public void UpdateCallRecordingStateTest() { - string accountId = "9900000"; - string callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; - UpdateCallRecording updateCallRecording = new UpdateCallRecording(RecordingStateEnum.Paused); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, null); - mockClient.Setup(x => x.Put("/accounts/{accountId}/calls/{callId}/recording", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.UpdateCallRecordingStateWithHttpInfo(accountId, callId, updateCallRecording); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string callId = null; + //UpdateCallRecording updateCallRecording = null; + //instance.UpdateCallRecordingState(accountId, callId, updateCallRecording); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/StatisticsApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/StatisticsApiTests.cs index 82017040..5bcb1a94 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/StatisticsApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/StatisticsApiTests.cs @@ -19,31 +19,25 @@ using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -using Bandwidth.Standard.Model; -using Moq; -using System.Net; +// uncomment below to import models +//using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Unit.Api +namespace Bandwidth.Standard.Test.Api { /// /// Class for testing StatisticsApi /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the API endpoint. + /// public class StatisticsApiTests : IDisposable { private StatisticsApi instance; - private Mock mockClient; - private Mock mockAsynchronousClient; - private Configuration fakeConfiguration; public StatisticsApiTests() { - mockClient = new Mock(); - mockAsynchronousClient = new Mock(); - fakeConfiguration = new Configuration(); - fakeConfiguration.BasePath = "https://voice.bandwidth.com/api/v2"; - fakeConfiguration.Username = "username"; - fakeConfiguration.Password = "password"; - instance = new StatisticsApi(mockClient.Object, mockAsynchronousClient.Object, fakeConfiguration); + instance = new StatisticsApi(); } public void Dispose() @@ -57,7 +51,8 @@ public void Dispose() [Fact] public void InstanceTest() { - Assert.IsType(instance); + // TODO uncomment below to test 'IsType' StatisticsApi + //Assert.IsType(instance); } /// @@ -66,15 +61,10 @@ public void InstanceTest() [Fact] public void GetStatisticsTest() { - string accountId = "9900000"; - var accountStatistics = new AccountStatistics(0, 900); - - var apiResponse = new ApiResponse(HttpStatusCode.OK, accountStatistics); - mockClient.Setup(x => x.Get("/accounts/{accountId}/statistics", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.GetStatisticsWithHttpInfo(accountId); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //var response = instance.GetStatistics(accountId); + //Assert.IsType(response); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/TollFreeVerificationApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/TollFreeVerificationApiTests.cs index 495e0a9c..fc771ce3 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/TollFreeVerificationApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/TollFreeVerificationApiTests.cs @@ -19,69 +19,25 @@ using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -using Bandwidth.Standard.Model; +// uncomment below to import models +//using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Unit.Api +namespace Bandwidth.Standard.Test.Api { /// /// Class for testing TollFreeVerificationApi /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the API endpoint. + /// public class TollFreeVerificationApiTests : IDisposable { private TollFreeVerificationApi instance; - private Configuration configuration; - - // private string accountId = "9900000"; - // private string tfPhoneNumber = "18005551234"; - - private WebhookSubscriptionRequestSchema webhookSubscriptionRequestSchema; - private Dictionary verification; public TollFreeVerificationApiTests() { - configuration = new Configuration(); - // configuration.BasePath = "http://127.0.0.1:4010"; - configuration.Username = Environment.GetEnvironmentVariable("BW_USERNAME"); - configuration.Password = Environment.GetEnvironmentVariable("BW_PASSWORD"); - instance = new TollFreeVerificationApi(configuration); - - webhookSubscriptionRequestSchema = new WebhookSubscriptionRequestSchema( - basicAuthentication: new TfvBasicAuthentication( - username: "username", - password: "password" - ), - callbackUrl: "https://example.com", - sharedSecretKey: "shared-secret-key" - ); - - verification = new Dictionary - { - { "businessAddress", new Address( - name: "name", - addr1: "addr1", - addr2: "addr2", - city: "city", - state: "state", - zip: "zip", - url: "url" - ) }, - { "businessContact", new Contact( - firstName: "John", - lastName: "Doe", - email: "email@email.com", - phoneNumber: "+1234567890" - ) }, - { "messageVolume", 12 }, - { "useCase", "useCase" }, - { "useCaseSummary", "useCaseSummary" }, - { "productionMessageContent", "productionMessageContent" }, - { "optInWorkflow", new OptInWorkflow( - description: "description", - imageUrls: new List { "imageUrls" } - ) }, - { "additionalInformation", "additionalInformation" }, - { "isvReseller", "isvReseller" } - }; + instance = new TollFreeVerificationApi(); } public void Dispose() @@ -95,7 +51,8 @@ public void Dispose() [Fact] public void InstanceTest() { - Assert.IsType(instance); + // TODO uncomment below to test 'IsType' TollFreeVerificationApi + //Assert.IsType(instance); } /// @@ -104,8 +61,11 @@ public void InstanceTest() [Fact] public void CreateWebhookSubscriptionTest() { - // var response = instance.CreateWebhookSubscriptionWithHttpInfo(accountId, webhookSubscriptionRequestSchema); - // Assert.IsType(response); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //WebhookSubscriptionRequestSchema webhookSubscriptionRequestSchema = null; + //var response = instance.CreateWebhookSubscription(accountId, webhookSubscriptionRequestSchema); + //Assert.IsType(response); } /// @@ -126,6 +86,7 @@ public void DeleteVerificationRequestTest() [Fact] public void DeleteWebhookSubscriptionTest() { + // TODO uncomment below to test the method and replace null with proper value //string accountId = null; //string id = null; //instance.DeleteWebhookSubscription(accountId, id); @@ -137,6 +98,7 @@ public void DeleteWebhookSubscriptionTest() [Fact] public void GetTollFreeVerificationStatusTest() { + // TODO uncomment below to test the method and replace null with proper value //string accountId = null; //string phoneNumber = null; //var response = instance.GetTollFreeVerificationStatus(accountId, phoneNumber); @@ -149,6 +111,7 @@ public void GetTollFreeVerificationStatusTest() [Fact] public void ListTollFreeUseCasesTest() { + // TODO uncomment below to test the method and replace null with proper value //var response = instance.ListTollFreeUseCases(); //Assert.IsType>(response); } @@ -159,6 +122,7 @@ public void ListTollFreeUseCasesTest() [Fact] public void ListWebhookSubscriptionsTest() { + // TODO uncomment below to test the method and replace null with proper value //string accountId = null; //var response = instance.ListWebhookSubscriptions(accountId); //Assert.IsType(response); @@ -170,6 +134,7 @@ public void ListWebhookSubscriptionsTest() [Fact] public void RequestTollFreeVerificationTest() { + // TODO uncomment below to test the method and replace null with proper value //string accountId = null; //VerificationRequest verificationRequest = null; //instance.RequestTollFreeVerification(accountId, verificationRequest); @@ -181,6 +146,7 @@ public void RequestTollFreeVerificationTest() [Fact] public void UpdateTollFreeVerificationRequestTest() { + // TODO uncomment below to test the method and replace null with proper value //string accountId = null; //string phoneNumber = null; //TfvSubmissionWrapper tfvSubmissionWrapper = null; @@ -193,6 +159,7 @@ public void UpdateTollFreeVerificationRequestTest() [Fact] public void UpdateWebhookSubscriptionTest() { + // TODO uncomment below to test the method and replace null with proper value //string accountId = null; //string id = null; //WebhookSubscriptionRequestSchema webhookSubscriptionRequestSchema = null; diff --git a/src/Bandwidth.Standard.Test/Unit/Api/TranscriptionsApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/TranscriptionsApiTests.cs index ebafc46a..de8c1f54 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/TranscriptionsApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/TranscriptionsApiTests.cs @@ -19,13 +19,10 @@ using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -using Moq; -using System.Net; -using System.Data.SqlTypes; -using Bandwidth.Standard.Model; -using System.Security.Authentication; +// uncomment below to import models +//using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Unit.Api +namespace Bandwidth.Standard.Test.Api { /// /// Class for testing TranscriptionsApi @@ -37,19 +34,10 @@ namespace Bandwidth.Standard.Test.Unit.Api public class TranscriptionsApiTests : IDisposable { private TranscriptionsApi instance; - private Mock mockClient; - private Mock mockAsynchronousClient; - private Configuration fakeConfiguration; public TranscriptionsApiTests() { - mockClient = new Mock(); - mockAsynchronousClient = new Mock(); - fakeConfiguration = new Configuration(); - fakeConfiguration.BasePath = "https://voice.bandwidth.com/api/v2"; - fakeConfiguration.Username = "username"; - fakeConfiguration.Password = "password"; - instance = new TranscriptionsApi(mockClient.Object, mockAsynchronousClient.Object, fakeConfiguration); + instance = new TranscriptionsApi(); } public void Dispose() @@ -63,7 +51,8 @@ public void Dispose() [Fact] public void InstanceTest() { - Assert.IsType(instance); + // TODO uncomment below to test 'IsType' TranscriptionsApi + //Assert.IsType(instance); } /// @@ -72,16 +61,11 @@ public void InstanceTest() [Fact] public void DeleteRealTimeTranscriptionTest() { - string accountId = "9900000"; - string callId = "c-12345"; - string transcriptionId = "t-12345"; - - var apiResponse = new ApiResponse(HttpStatusCode.NoContent, null); - mockClient.Setup(x => x.Delete("/accounts/{accountId}/calls/{callId}/transcriptions/{transcriptionId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.DeleteRealTimeTranscriptionWithHttpInfo(accountId, callId, transcriptionId); - - Assert.IsType>(response); - Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string callId = null; + //string transcriptionId = null; + //instance.DeleteRealTimeTranscription(accountId, callId, transcriptionId); } /// @@ -90,24 +74,12 @@ public void DeleteRealTimeTranscriptionTest() [Fact] public void GetRealTimeTranscriptionTest() { - string accountId = "9900000"; - string callId = "c-12345"; - string transcriptionId = "t-12345"; - - CallTranscriptionDetectedLanguageEnum detectedLanguage = CallTranscriptionDetectedLanguageEnum.EnUS; - CallTranscriptionTrackEnum track = CallTranscriptionTrackEnum.Inbound; - - CallTranscription transcription = new CallTranscription(detectedLanguage: detectedLanguage, track: track, transcript: "abc 123 this is a test", confidence: 0.9); - - List tracks = new List { transcription }; - - CallTranscriptionResponse callTranscriptionResponse = new CallTranscriptionResponse(accountId: accountId, callId: callId, transcriptionId: transcriptionId, tracks: tracks); - - var apiResponse = new ApiResponse(HttpStatusCode.NoContent, callTranscriptionResponse); - mockClient.Setup(x => x.Get("/accounts/{accountId}/calls/{callId}/transcriptions/{transcriptionId}", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.GetRealTimeTranscription(accountId, callId, transcriptionId); - - Assert.IsType(response); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string callId = null; + //string transcriptionId = null; + //var response = instance.GetRealTimeTranscription(accountId, callId, transcriptionId); + //Assert.IsType(response); } /// @@ -116,17 +88,11 @@ public void GetRealTimeTranscriptionTest() [Fact] public void ListRealTimeTranscriptionsTest() { - string accountId = "9900000"; - string callId = "c-12345"; - - CallTranscriptionMetadata transcription = new CallTranscriptionMetadata(transcriptionId: "t-12345", transcriptionUrl: "https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-12345/transcriptions/t-12345"); - List callTranscriptions = new List { transcription }; - - var apiResponse = new ApiResponse>(HttpStatusCode.NoContent, callTranscriptions); - mockClient.Setup(x => x.Get>("/accounts/{accountId}/calls/{callId}/transcriptions", It.IsAny(), fakeConfiguration)).Returns(apiResponse); - var response = instance.ListRealTimeTranscriptions(accountId, callId); - - Assert.IsType>(response); + // TODO uncomment below to test the method and replace null with proper value + //string accountId = null; + //string callId = null; + //var response = instance.ListRealTimeTranscriptions(accountId, callId); + //Assert.IsType>(response); } } } From de53fea989001db9192cc33f7d35c4c2b9489967 Mon Sep 17 00:00:00 2001 From: ckoegel Date: Mon, 6 Jul 2026 16:34:10 -0400 Subject: [PATCH 4/7] more tests --- .../Unit/Api/MFAApiTests.cs | 94 +++++++----- .../Unit/Api/MediaApiTests.cs | 78 +++++----- .../Unit/Api/MessagesApiTests.cs | 138 +++++++++++------- .../Unit/Api/MultiChannelApiTests.cs | 73 ++++++--- .../Unit/Api/PhoneNumberLookupApiTests.cs | 115 +++++++++++---- 5 files changed, 319 insertions(+), 179 deletions(-) diff --git a/src/Bandwidth.Standard.Test/Unit/Api/MFAApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/MFAApiTests.cs index 2e56801b..a233a0b6 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/MFAApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/MFAApiTests.cs @@ -9,35 +9,41 @@ */ using System; -using System.IO; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using RestSharp; +using System.Net; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -// uncomment below to import models -//using Bandwidth.Standard.Model; +using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Api +namespace Bandwidth.Standard.Test.Unit.Api { /// - /// Class for testing MFAApi + /// MFAApi Unit Tests /// - /// - /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). - /// Please update the test case below to test the API endpoint. - /// public class MFAApiTests : IDisposable { - private MFAApi instance; + private readonly MFAApi instance; + + private readonly string accountId = Environment.GetEnvironmentVariable("BW_ACCOUNT_ID"); + private readonly string userNumber = Environment.GetEnvironmentVariable("USER_NUMBER"); + private readonly string bwNumber = Environment.GetEnvironmentVariable("BW_NUMBER"); + private readonly string messagingApplicationId = Environment.GetEnvironmentVariable("BW_MESSAGING_APPLICATION_ID"); + private readonly string voiceApplicationId = Environment.GetEnvironmentVariable("BW_VOICE_APPLICATION_ID"); + + private readonly string message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + private readonly int digits = 6; public MFAApiTests() { - instance = new MFAApi(); + Configuration configuration = new() + { + BasePath = "http://127.0.0.1:4010", + IgnoreOperationServers = true, + OAuthClientId = Environment.GetEnvironmentVariable("BW_CLIENT_ID"), + OAuthClientSecret = Environment.GetEnvironmentVariable("BW_CLIENT_SECRET") + }; + instance = new MFAApi(configuration); } public void Dispose() @@ -51,8 +57,7 @@ public void Dispose() [Fact] public void InstanceTest() { - // TODO uncomment below to test 'IsType' MFAApi - //Assert.IsType(instance); + Assert.IsType(instance); } /// @@ -61,11 +66,19 @@ public void InstanceTest() [Fact] public void GenerateMessagingCodeTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //CodeRequest codeRequest = null; - //var response = instance.GenerateMessagingCode(accountId, codeRequest); - //Assert.IsType(response); + CodeRequest codeRequest = new( + to: userNumber, + from: bwNumber, + applicationId: messagingApplicationId, + message: message, + digits: digits + ); + + ApiResponse response = instance.GenerateMessagingCodeWithHttpInfo(accountId, codeRequest); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.Equal(29, response.Data.MessageId.Length); } /// @@ -74,11 +87,19 @@ public void GenerateMessagingCodeTest() [Fact] public void GenerateVoiceCodeTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //CodeRequest codeRequest = null; - //var response = instance.GenerateVoiceCode(accountId, codeRequest); - //Assert.IsType(response); + CodeRequest codeRequest = new( + to: userNumber, + from: bwNumber, + applicationId: voiceApplicationId, + message: message, + digits: digits + ); + + ApiResponse response = instance.GenerateVoiceCodeWithHttpInfo(accountId, codeRequest); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.Equal(47, response.Data.CallId.Length); } /// @@ -87,11 +108,18 @@ public void GenerateVoiceCodeTest() [Fact] public void VerifyCodeTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //VerifyCodeRequest verifyCodeRequest = null; - //var response = instance.VerifyCode(accountId, verifyCodeRequest); - //Assert.IsType(response); + VerifyCodeRequest verifyCodeRequest = new( + to: userNumber, + scope: "login", + expirationTimeInMinutes: 3, + code: "12345" + ); + + ApiResponse response = instance.VerifyCodeWithHttpInfo(accountId, verifyCodeRequest); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType(response.Data.Valid); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/MediaApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/MediaApiTests.cs index b669f442..ad758fe8 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/MediaApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/MediaApiTests.cs @@ -11,33 +11,36 @@ using System; using System.IO; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using RestSharp; +using System.Net; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -// uncomment below to import models -//using Bandwidth.Standard.Model; +using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Api +namespace Bandwidth.Standard.Test.Unit.Api { /// - /// Class for testing MediaApi + /// MediaApi Unit Tests /// - /// - /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). - /// Please update the test case below to test the API endpoint. - /// public class MediaApiTests : IDisposable { - private MediaApi instance; + private readonly MediaApi instance; + + private readonly string accountId = Environment.GetEnvironmentVariable("BW_ACCOUNT_ID"); + + private readonly string mediaName = "csharp_binary_media"; public MediaApiTests() { - instance = new MediaApi(); + Configuration configuration = new() + { + BasePath = "http://127.0.0.1:4010", + IgnoreOperationServers = true, + OAuthClientId = Environment.GetEnvironmentVariable("BW_CLIENT_ID"), + OAuthClientSecret = Environment.GetEnvironmentVariable("BW_CLIENT_SECRET") + }; + instance = new MediaApi(configuration); } public void Dispose() @@ -51,8 +54,7 @@ public void Dispose() [Fact] public void InstanceTest() { - // TODO uncomment below to test 'IsType' MediaApi - //Assert.IsType(instance); + Assert.IsType(instance); } /// @@ -61,23 +63,21 @@ public void InstanceTest() [Fact] public void DeleteMediaTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string mediaId = null; - //instance.DeleteMedia(accountId, mediaId); + ApiResponse response = instance.DeleteMediaWithHttpInfo(accountId, mediaName); + + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } /// /// Test GetMedia /// - [Fact] + [Fact(Skip = "Can't set the correct Accept header for Prism")] public void GetMediaTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string mediaId = null; - //var response = instance.GetMedia(accountId, mediaId); - //Assert.IsType(response); + ApiResponse response = instance.GetMediaWithHttpInfo(accountId, mediaName); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); } /// @@ -86,26 +86,26 @@ public void GetMediaTest() [Fact] public void ListMediaTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string continuationToken = null; - //var response = instance.ListMedia(accountId, continuationToken); - //Assert.IsType>(response); + ApiResponse> response = instance.ListMediaWithHttpInfo(accountId); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data[0]); + Assert.IsType(response.Data[0].Content); + Assert.IsType(response.Data[0].ContentLength); + Assert.IsType(response.Data[0].MediaName); } /// /// Test UploadMedia /// - [Fact] + [Fact(Skip = "Can't set the correct Content-Type and Accept headers for Prism")] public void UploadMediaTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string mediaId = null; - //System.IO.Stream body = null; - //string contentType = null; - //string cacheControl = null; - //instance.UploadMedia(accountId, mediaId, body, contentType, cacheControl); + Stream body = new MemoryStream(); + + ApiResponse response = instance.UploadMediaWithHttpInfo(accountId, mediaName, body, "image/jpeg", "no-cache"); + + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/MessagesApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/MessagesApiTests.cs index 4cb4e131..3f8e986a 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/MessagesApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/MessagesApiTests.cs @@ -9,35 +9,41 @@ */ using System; -using System.IO; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using RestSharp; +using System.Net; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -// uncomment below to import models -//using Bandwidth.Standard.Model; +using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Api +namespace Bandwidth.Standard.Test.Unit.Api { /// - /// Class for testing MessagesApi + /// MessagesApi Unit Tests /// - /// - /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). - /// Please update the test case below to test the API endpoint. - /// public class MessagesApiTests : IDisposable { - private MessagesApi instance; + private readonly MessagesApi instance; + + private readonly string accountId = Environment.GetEnvironmentVariable("BW_ACCOUNT_ID"); + private readonly string messagingApplicationId = Environment.GetEnvironmentVariable("BW_MESSAGING_APPLICATION_ID"); + private readonly string bwNumber = Environment.GetEnvironmentVariable("BW_NUMBER"); + + private readonly string messageText = "C# SDK Test Message"; + private readonly PriorityEnum messagePriority = PriorityEnum.High; + private readonly DateTime expiration = DateTime.UtcNow.AddDays(1); public MessagesApiTests() { - instance = new MessagesApi(); + Configuration configuration = new() + { + BasePath = "http://127.0.0.1:4010", + IgnoreOperationServers = true, + OAuthClientId = Environment.GetEnvironmentVariable("BW_CLIENT_ID"), + OAuthClientSecret = Environment.GetEnvironmentVariable("BW_CLIENT_SECRET") + }; + instance = new MessagesApi(configuration); } public void Dispose() @@ -51,8 +57,7 @@ public void Dispose() [Fact] public void InstanceTest() { - // TODO uncomment below to test 'IsType' MessagesApi - //Assert.IsType(instance); + Assert.IsType(instance); } /// @@ -61,11 +66,34 @@ public void InstanceTest() [Fact] public void CreateMessageTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //MessageRequest messageRequest = null; - //var response = instance.CreateMessage(accountId, messageRequest); - //Assert.IsType(response); + MessageRequest messageRequest = new( + applicationId: messagingApplicationId, + from: bwNumber, + to: new List { bwNumber }, + text: messageText, + priority: messagePriority, + expiration: expiration + ); + + ApiResponse response = instance.CreateMessageWithHttpInfo(accountId, messageRequest); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.IsType(response.Data); + Assert.Equal(29, response.Data.Id.Length); + Assert.Equal(12, response.Data.Owner.Length); + Assert.Equal(36, response.Data.ApplicationId.Length); + Assert.IsType(response.Data.Time); + Assert.IsType(response.Data.SegmentCount); + Assert.IsType(response.Data.Direction); + Assert.IsType>(response.Data.To); + Assert.Equal(12, response.Data.To[0].Length); + Assert.Equal(12, response.Data.From.Length); + Assert.IsType>(response.Data.Media); + Assert.IsType(response.Data.Media[0]); + Assert.IsType(response.Data.Text); + Assert.IsType(response.Data.Tag); + Assert.IsType(response.Data.Priority); + Assert.IsType(response.Data.Expiration); } /// @@ -74,37 +102,41 @@ public void CreateMessageTest() [Fact] public void ListMessagesTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string messageId = null; - //string sourceTn = null; - //string destinationTn = null; - //MessageStatusEnum? messageStatus = null; - //ListMessageDirectionEnum? messageDirection = null; - //string carrierName = null; - //MessageTypeEnum? messageType = null; - //int? errorCode = null; - //string fromDateTime = null; - //string toDateTime = null; - //string campaignId = null; - //int? fromBwLatency = null; - //bool? bwQueued = null; - //ProductTypeEnum? product = null; - //string location = null; - //bool? carrierQueued = null; - //int? fromCarrierLatency = null; - //string callingNumberCountryA3 = null; - //string calledNumberCountryA3 = null; - //int? fromSegmentCount = null; - //int? toSegmentCount = null; - //int? fromMessageSize = null; - //int? toMessageSize = null; - //string sort = null; - //string pageToken = null; - //int? limit = null; - //bool? limitTotalCount = null; - //var response = instance.ListMessages(accountId, messageId, sourceTn, destinationTn, messageStatus, messageDirection, carrierName, messageType, errorCode, fromDateTime, toDateTime, campaignId, fromBwLatency, bwQueued, product, location, carrierQueued, fromCarrierLatency, callingNumberCountryA3, calledNumberCountryA3, fromSegmentCount, toSegmentCount, fromMessageSize, toMessageSize, sort, pageToken, limit, limitTotalCount); - //Assert.IsType(response); + ApiResponse response = instance.ListMessagesWithHttpInfo(accountId); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType(response.Data.TotalCount); + Assert.IsType(response.Data.PageInfo); + Assert.IsType(response.Data.PageInfo.PrevPage); + Assert.IsType(response.Data.PageInfo.NextPage); + Assert.IsType(response.Data.PageInfo.PrevPageToken); + Assert.IsType(response.Data.PageInfo.NextPageToken); + Assert.IsType>(response.Data.Messages); + Assert.IsType(response.Data.Messages[0]); + Assert.Equal(29, response.Data.Messages[0].MessageId.Length); + Assert.Equal(7, response.Data.Messages[0].AccountId.Length); + Assert.Equal(12, response.Data.Messages[0].SourceTn.Length); + Assert.Equal(12, response.Data.Messages[0].DestinationTn.Length); + Assert.IsType(response.Data.Messages[0].MessageStatus); + Assert.IsType(response.Data.Messages[0].MessageDirection); + Assert.IsType(response.Data.Messages[0].MessageType); + Assert.IsType(response.Data.Messages[0].SegmentCount); + Assert.IsType(response.Data.Messages[0].ErrorCode); + Assert.IsType(response.Data.Messages[0].ReceiveTime); + Assert.IsType(response.Data.Messages[0].CarrierName); + Assert.IsType(response.Data.Messages[0].MessageSize); + Assert.IsType(response.Data.Messages[0].MessageLength); + Assert.IsType(response.Data.Messages[0].AttachmentCount); + Assert.IsType(response.Data.Messages[0].RecipientCount); + Assert.IsType(response.Data.Messages[0].CampaignClass); + Assert.IsType(response.Data.Messages[0].CampaignId); + Assert.IsType(response.Data.Messages[0].BwLatency); + Assert.IsType(response.Data.Messages[0].CarrierLatency); + Assert.IsType(response.Data.Messages[0].CallingNumberCountryA3); + Assert.IsType(response.Data.Messages[0].CalledNumberCountryA3); + Assert.IsType(response.Data.Messages[0].Product); + Assert.IsType(response.Data.Messages[0].Location); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/MultiChannelApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/MultiChannelApiTests.cs index dbdb1fe2..79557886 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/MultiChannelApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/MultiChannelApiTests.cs @@ -9,35 +9,38 @@ */ using System; -using System.IO; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using RestSharp; +using System.Net; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -// uncomment below to import models -//using Bandwidth.Standard.Model; +using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Api +namespace Bandwidth.Standard.Test.Unit.Api { /// - /// Class for testing MultiChannelApi + /// MultiChannelApi Unit Tests /// - /// - /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). - /// Please update the test case below to test the API endpoint. - /// public class MultiChannelApiTests : IDisposable { - private MultiChannelApi instance; + private readonly MultiChannelApi instance; + + private readonly string accountId = Environment.GetEnvironmentVariable("BW_ACCOUNT_ID"); + private readonly string userNumber = Environment.GetEnvironmentVariable("USER_NUMBER"); + private readonly string bwNumber = Environment.GetEnvironmentVariable("BW_NUMBER"); + private readonly string messagingApplicationId = Environment.GetEnvironmentVariable("BW_MESSAGING_APPLICATION_ID"); public MultiChannelApiTests() { - instance = new MultiChannelApi(); + Configuration configuration = new() + { + BasePath = "http://127.0.0.1:4010", + IgnoreOperationServers = true, + OAuthClientId = Environment.GetEnvironmentVariable("BW_CLIENT_ID"), + OAuthClientSecret = Environment.GetEnvironmentVariable("BW_CLIENT_SECRET") + }; + instance = new MultiChannelApi(configuration); } public void Dispose() @@ -51,8 +54,7 @@ public void Dispose() [Fact] public void InstanceTest() { - // TODO uncomment below to test 'IsType' MultiChannelApi - //Assert.IsType(instance); + Assert.IsType(instance); } /// @@ -61,11 +63,38 @@ public void InstanceTest() [Fact] public void CreateMultiChannelMessageTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //MultiChannelMessageRequest multiChannelMessageRequest = null; - //var response = instance.CreateMultiChannelMessage(accountId, multiChannelMessageRequest); - //Assert.IsType(response); + MultiChannelChannelListSMSObject smsObject = new( + from: bwNumber, + applicationId: messagingApplicationId, + channel: MultiChannelMessageChannelEnum.SMS, + content: new SmsMessageContent(text: "Hello World!") + ); + MultiChannelChannelListRequestObject channelListSMSObject = new(smsObject); + + MultiChannelMessageRequest smsRequest = new( + to: userNumber, + tag: "tag", + priority: PriorityEnum.High, + expiration: DateTime.UtcNow.AddSeconds(60), + channelList: new List { channelListSMSObject } + ); + + ApiResponse response = instance.CreateMultiChannelMessageWithHttpInfo(accountId, smsRequest); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType>(response.Data.Links); + Assert.IsType(response.Data.Data); + Assert.IsType(response.Data.Data.Id); + Assert.IsType(response.Data.Data.Time); + Assert.IsType(response.Data.Data.Direction); + Assert.IsType>(response.Data.Data.To); + Assert.IsType(response.Data.Data.Tag); + Assert.IsType(response.Data.Data.Priority); + Assert.IsType(response.Data.Data.Expiration); + Assert.IsType>(response.Data.Data.ChannelList); + Assert.IsType(response.Data.Data.ChannelList[0]); + Assert.IsType>(response.Data.Errors); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/PhoneNumberLookupApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/PhoneNumberLookupApiTests.cs index a9c77c19..3164f99a 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/PhoneNumberLookupApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/PhoneNumberLookupApiTests.cs @@ -9,35 +9,35 @@ */ using System; -using System.IO; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using RestSharp; +using System.Net; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -// uncomment below to import models -//using Bandwidth.Standard.Model; +using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Api +namespace Bandwidth.Standard.Test.Unit.Api { /// - /// Class for testing PhoneNumberLookupApi + /// PhoneNumberLookupApi Unit Tests /// - /// - /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). - /// Please update the test case below to test the API endpoint. - /// public class PhoneNumberLookupApiTests : IDisposable { - private PhoneNumberLookupApi instance; + private readonly PhoneNumberLookupApi instance; + + private readonly string accountId = Environment.GetEnvironmentVariable("BW_ACCOUNT_ID"); public PhoneNumberLookupApiTests() { - instance = new PhoneNumberLookupApi(); + Configuration configuration = new() + { + BasePath = "http://127.0.0.1:4010", + IgnoreOperationServers = true, + OAuthClientId = Environment.GetEnvironmentVariable("BW_CLIENT_ID"), + OAuthClientSecret = Environment.GetEnvironmentVariable("BW_CLIENT_SECRET") + }; + instance = new PhoneNumberLookupApi(configuration); } public void Dispose() @@ -51,8 +51,7 @@ public void Dispose() [Fact] public void InstanceTest() { - // TODO uncomment below to test 'IsType' PhoneNumberLookupApi - //Assert.IsType(instance); + Assert.IsType(instance); } /// @@ -61,11 +60,24 @@ public void InstanceTest() [Fact] public void CreateAsyncBulkLookupTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //AsyncLookupRequest asyncLookupRequest = null; - //var response = instance.CreateAsyncBulkLookup(accountId, asyncLookupRequest); - //Assert.IsType(response); + AsyncLookupRequest asyncLookupRequest = new( + phoneNumbers: new List { "+1234567890", "+1987654321" } + ); + + ApiResponse response = instance.CreateAsyncBulkLookupWithHttpInfo(accountId, asyncLookupRequest); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType>(response.Data.Links); + Assert.IsType(response.Data.Links[0]); + Assert.IsType(response.Data.Links[0].Rel); + Assert.IsType(response.Data.Links[0].Href); + Assert.IsType(response.Data.Links[0].Method); + Assert.IsType(response.Data.Data); + Assert.IsType(response.Data.Data.RequestId); + Assert.IsType(response.Data.Data.Status); + Assert.Equal(InProgressLookupStatusEnum.INPROGRESS, response.Data.Data.Status); + Assert.IsType>(response.Data.Errors); } /// @@ -74,11 +86,32 @@ public void CreateAsyncBulkLookupTest() [Fact] public void CreateSyncLookupTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //SyncLookupRequest syncLookupRequest = null; - //var response = instance.CreateSyncLookup(accountId, syncLookupRequest); - //Assert.IsType(response); + SyncLookupRequest syncLookupRequest = new( + phoneNumbers: new List { "+1234567890", "+1987654321" }, + rcsAgent: "TestAgent" + ); + + ApiResponse response = instance.CreateSyncLookupWithHttpInfo(accountId, syncLookupRequest); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType>(response.Data.Links); + Assert.IsType(response.Data.Data); + Assert.IsType(response.Data.Data.RequestId); + Assert.IsType(response.Data.Data.Status); + Assert.Equal(CompletedLookupStatusEnum.COMPLETE, response.Data.Data.Status); + Assert.IsType>(response.Data.Data.Results); + Assert.IsType(response.Data.Data.Results[0]); + Assert.IsType(response.Data.Data.Results[0].PhoneNumber); + Assert.IsType(response.Data.Data.Results[0].LineType); + Assert.IsType(response.Data.Data.Results[0].MessagingProvider); + Assert.IsType(response.Data.Data.Results[0].VoiceProvider); + Assert.IsType(response.Data.Data.Results[0].CountryCodeA3); + Assert.IsType(response.Data.Data.Results[0].LatestMessageDeliveryStatus); + Assert.Equal(LatestMessageDeliveryStatusEnum.ACTIVE, response.Data.Data.Results[0].LatestMessageDeliveryStatus); + Assert.IsType(response.Data.Data.Results[0].InitialMessageDeliveryStatusDate); + Assert.IsType(response.Data.Data.Results[0].LatestMessageDeliveryStatusDate); + Assert.IsType>(response.Data.Errors); } /// @@ -87,11 +120,29 @@ public void CreateSyncLookupTest() [Fact] public void GetAsyncBulkLookupTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //Guid requestId = null; - //var response = instance.GetAsyncBulkLookup(accountId, requestId); - //Assert.IsType(response); + Guid requestId = Guid.Parse("123e4567-e89b-12d3-a456-426614174000"); + + ApiResponse response = instance.GetAsyncBulkLookupWithHttpInfo(accountId, requestId); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType>(response.Data.Links); + Assert.IsType(response.Data.Data); + Assert.IsType(response.Data.Data.RequestId); + Assert.IsType(response.Data.Data.Status); + Assert.Equal(InProgressLookupStatusEnum.COMPLETE, response.Data.Data.Status); + Assert.IsType>(response.Data.Data.Results); + Assert.IsType(response.Data.Data.Results[0]); + Assert.IsType(response.Data.Data.Results[0].PhoneNumber); + Assert.IsType(response.Data.Data.Results[0].LineType); + Assert.IsType(response.Data.Data.Results[0].MessagingProvider); + Assert.IsType(response.Data.Data.Results[0].VoiceProvider); + Assert.IsType(response.Data.Data.Results[0].CountryCodeA3); + Assert.IsType(response.Data.Data.Results[0].LatestMessageDeliveryStatus); + Assert.Equal(LatestMessageDeliveryStatusEnum.ACTIVE, response.Data.Data.Results[0].LatestMessageDeliveryStatus); + Assert.IsType(response.Data.Data.Results[0].InitialMessageDeliveryStatusDate); + Assert.IsType(response.Data.Data.Results[0].LatestMessageDeliveryStatusDate); + Assert.IsType>(response.Data.Errors); } } } From 81cd86a021ba1cd0e17c039c51b5bd111dd65443 Mon Sep 17 00:00:00 2001 From: ckoegel Date: Mon, 6 Jul 2026 16:34:17 -0400 Subject: [PATCH 5/7] update conferences --- src/Bandwidth.Standard.Test/Unit/Api/ConferencesApiTests.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Bandwidth.Standard.Test/Unit/Api/ConferencesApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/ConferencesApiTests.cs index 0557716d..34de4657 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/ConferencesApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/ConferencesApiTests.cs @@ -89,6 +89,7 @@ public void GetConferenceTest() Assert.IsType(response.Data.ConferenceEventUrl); Assert.IsType(response.Data.ConferenceEventMethod); Assert.IsType(response.Data.Tag); + Assert.IsType>(response.Data.ActiveMembers); } /// @@ -130,6 +131,7 @@ public void GetConferenceRecordingTest() Assert.IsType(response.Data.FileFormat); Assert.IsType(response.Data.Status); Assert.IsType(response.Data.MediaUrl); + Assert.IsType(response.Data.RecordingName); } /// @@ -153,6 +155,7 @@ public void ListConferenceRecordingsTest() Assert.IsType(response.Data[0].FileFormat); Assert.IsType(response.Data[0].Status); Assert.IsType(response.Data[0].MediaUrl); + Assert.IsType(response.Data[0].RecordingName); } /// From c7a6832070912138e72da420534ce460f14f8d02 Mon Sep 17 00:00:00 2001 From: ckoegel Date: Mon, 6 Jul 2026 16:53:16 -0400 Subject: [PATCH 6/7] final 4 tests --- .../Unit/Api/RecordingsApiTests.cs | 218 ++++++++++++------ .../Unit/Api/StatisticsApiTests.cs | 44 ++-- .../Unit/Api/TollFreeVerificationApiTests.cs | 214 ++++++++++++----- .../Unit/Api/TranscriptionsApiTests.cs | 76 +++--- 4 files changed, 366 insertions(+), 186 deletions(-) diff --git a/src/Bandwidth.Standard.Test/Unit/Api/RecordingsApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/RecordingsApiTests.cs index 372b7cd2..60c57982 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/RecordingsApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/RecordingsApiTests.cs @@ -11,33 +11,37 @@ using System; using System.IO; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using RestSharp; +using System.Net; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -// uncomment below to import models -//using Bandwidth.Standard.Model; +using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Api +namespace Bandwidth.Standard.Test.Unit.Api { /// - /// Class for testing RecordingsApi + /// RecordingsApi Unit Tests /// - /// - /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). - /// Please update the test case below to test the API endpoint. - /// public class RecordingsApiTests : IDisposable { - private RecordingsApi instance; + private readonly RecordingsApi instance; + + private readonly string accountId = Environment.GetEnvironmentVariable("BW_ACCOUNT_ID"); + + private readonly string callId = "c-1234"; + private readonly string recordingId = "r-1234"; public RecordingsApiTests() { - instance = new RecordingsApi(); + Configuration configuration = new() + { + BasePath = "http://127.0.0.1:4010", + IgnoreOperationServers = true, + OAuthClientId = Environment.GetEnvironmentVariable("BW_CLIENT_ID"), + OAuthClientSecret = Environment.GetEnvironmentVariable("BW_CLIENT_SECRET") + }; + instance = new RecordingsApi(configuration); } public void Dispose() @@ -51,8 +55,7 @@ public void Dispose() [Fact] public void InstanceTest() { - // TODO uncomment below to test 'IsType' RecordingsApi - //Assert.IsType(instance); + Assert.IsType(instance); } /// @@ -61,11 +64,9 @@ public void InstanceTest() [Fact] public void DeleteRecordingTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string callId = null; - //string recordingId = null; - //instance.DeleteRecording(accountId, callId, recordingId); + ApiResponse response = instance.DeleteRecordingWithHttpInfo(accountId, callId, recordingId); + + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } /// @@ -74,11 +75,9 @@ public void DeleteRecordingTest() [Fact] public void DeleteRecordingMediaTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string callId = null; - //string recordingId = null; - //instance.DeleteRecordingMedia(accountId, callId, recordingId); + ApiResponse response = instance.DeleteRecordingMediaWithHttpInfo(accountId, callId, recordingId); + + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } /// @@ -87,25 +86,21 @@ public void DeleteRecordingMediaTest() [Fact] public void DeleteRecordingTranscriptionTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string callId = null; - //string recordingId = null; - //instance.DeleteRecordingTranscription(accountId, callId, recordingId); + ApiResponse response = instance.DeleteRecordingTranscriptionWithHttpInfo(accountId, callId, recordingId); + + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } /// /// Test DownloadCallRecording /// - [Fact] + [Fact(Skip = "Can't set the correct Accept header for Prism")] public void DownloadCallRecordingTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string callId = null; - //string recordingId = null; - //var response = instance.DownloadCallRecording(accountId, callId, recordingId); - //Assert.IsType(response); + ApiResponse response = instance.DownloadCallRecordingWithHttpInfo(accountId, callId, recordingId); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); } /// @@ -114,12 +109,33 @@ public void DownloadCallRecordingTest() [Fact] public void GetCallRecordingTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string callId = null; - //string recordingId = null; - //var response = instance.GetCallRecording(accountId, callId, recordingId); - //Assert.IsType(response); + ApiResponse response = instance.GetCallRecordingWithHttpInfo(accountId, callId, recordingId); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.Equal(36, response.Data.ApplicationId.Length); + Assert.Equal(7, response.Data.AccountId.Length); + Assert.Equal(47, response.Data.CallId.Length); + Assert.Equal(47, response.Data.ParentCallId.Length); + Assert.Equal(47, response.Data.RecordingId.Length); + Assert.Equal(12, response.Data.To.Length); + Assert.Equal(12, response.Data.From.Length); + Assert.Equal(12, response.Data.TransferCallerId.Length); + Assert.Equal(12, response.Data.TransferTo.Length); + Assert.IsType(response.Data.Duration); + Assert.IsType(response.Data.Direction); + Assert.IsType(response.Data.Channels); + Assert.IsType(response.Data.StartTime); + Assert.IsType(response.Data.EndTime); + Assert.IsType(response.Data.FileFormat); + Assert.IsType(response.Data.Status); + Assert.IsType(response.Data.MediaUrl); + Assert.IsType(response.Data.Transcription); + Assert.Equal(38, response.Data.Transcription.Id.Length); + Assert.IsType(response.Data.Transcription.Status); + Assert.IsType(response.Data.Transcription.CompletedTime); + Assert.IsType(response.Data.Transcription.Url); + Assert.IsType(response.Data.RecordingName); } /// @@ -128,12 +144,22 @@ public void GetCallRecordingTest() [Fact] public void GetRecordingTranscriptionTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string callId = null; - //string recordingId = null; - //var response = instance.GetRecordingTranscription(accountId, callId, recordingId); - //Assert.IsType(response); + ApiResponse response = instance.GetRecordingTranscriptionWithHttpInfo(accountId, callId, recordingId); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType>(response.Data.Transcripts); + Assert.IsType(response.Data.Transcripts[0]); + Assert.IsType(response.Data.Transcripts[0].Speaker); + Assert.IsType(response.Data.Transcripts[0].Text); + Assert.IsType(response.Data.Transcripts[0].Confidence); + Assert.IsType>(response.Data.Clips); + Assert.IsType(response.Data.Clips[0]); + Assert.IsType(response.Data.Clips[0].Speaker); + Assert.IsType(response.Data.Clips[0].Text); + Assert.IsType(response.Data.Clips[0].Confidence); + Assert.IsType(response.Data.Clips[0].StartTimeSeconds); + Assert.IsType(response.Data.Clips[0].EndTimeSeconds); } /// @@ -142,14 +168,33 @@ public void GetRecordingTranscriptionTest() [Fact] public void ListAccountCallRecordingsTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string to = null; - //string from = null; - //string minStartTime = null; - //string maxStartTime = null; - //var response = instance.ListAccountCallRecordings(accountId, to, from, minStartTime, maxStartTime); - //Assert.IsType>(response); + ApiResponse> response = instance.ListAccountCallRecordingsWithHttpInfo(accountId); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data[0]); + Assert.Equal(36, response.Data[0].ApplicationId.Length); + Assert.Equal(7, response.Data[0].AccountId.Length); + Assert.Equal(47, response.Data[0].CallId.Length); + Assert.Equal(47, response.Data[0].ParentCallId.Length); + Assert.Equal(47, response.Data[0].RecordingId.Length); + Assert.Equal(12, response.Data[0].To.Length); + Assert.Equal(12, response.Data[0].From.Length); + Assert.Equal(12, response.Data[0].TransferCallerId.Length); + Assert.Equal(12, response.Data[0].TransferTo.Length); + Assert.IsType(response.Data[0].Duration); + Assert.IsType(response.Data[0].Direction); + Assert.IsType(response.Data[0].Channels); + Assert.IsType(response.Data[0].StartTime); + Assert.IsType(response.Data[0].EndTime); + Assert.IsType(response.Data[0].FileFormat); + Assert.IsType(response.Data[0].Status); + Assert.IsType(response.Data[0].MediaUrl); + Assert.IsType(response.Data[0].Transcription); + Assert.Equal(38, response.Data[0].Transcription.Id.Length); + Assert.IsType(response.Data[0].Transcription.Status); + Assert.IsType(response.Data[0].Transcription.CompletedTime); + Assert.IsType(response.Data[0].Transcription.Url); + Assert.IsType(response.Data[0].RecordingName); } /// @@ -158,11 +203,33 @@ public void ListAccountCallRecordingsTest() [Fact] public void ListCallRecordingsTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string callId = null; - //var response = instance.ListCallRecordings(accountId, callId); - //Assert.IsType>(response); + ApiResponse> response = instance.ListCallRecordingsWithHttpInfo(accountId, callId); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data[0]); + Assert.Equal(36, response.Data[0].ApplicationId.Length); + Assert.Equal(7, response.Data[0].AccountId.Length); + Assert.Equal(47, response.Data[0].CallId.Length); + Assert.Equal(47, response.Data[0].ParentCallId.Length); + Assert.Equal(47, response.Data[0].RecordingId.Length); + Assert.Equal(12, response.Data[0].To.Length); + Assert.Equal(12, response.Data[0].From.Length); + Assert.Equal(12, response.Data[0].TransferCallerId.Length); + Assert.Equal(12, response.Data[0].TransferTo.Length); + Assert.IsType(response.Data[0].Duration); + Assert.IsType(response.Data[0].Direction); + Assert.IsType(response.Data[0].Channels); + Assert.IsType(response.Data[0].StartTime); + Assert.IsType(response.Data[0].EndTime); + Assert.IsType(response.Data[0].FileFormat); + Assert.IsType(response.Data[0].Status); + Assert.IsType(response.Data[0].MediaUrl); + Assert.IsType(response.Data[0].Transcription); + Assert.Equal(38, response.Data[0].Transcription.Id.Length); + Assert.IsType(response.Data[0].Transcription.Status); + Assert.IsType(response.Data[0].Transcription.CompletedTime); + Assert.IsType(response.Data[0].Transcription.Url); + Assert.IsType(response.Data[0].RecordingName); } /// @@ -171,12 +238,13 @@ public void ListCallRecordingsTest() [Fact] public void TranscribeCallRecordingTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string callId = null; - //string recordingId = null; - //TranscribeRecording transcribeRecording = null; - //instance.TranscribeCallRecording(accountId, callId, recordingId, transcribeRecording); + TranscribeRecording transcribeRecording = new( + callbackUrl: "https://myServer.example/bandwidth/webhooks/transcriptionAvailable" + ); + + ApiResponse response = instance.TranscribeCallRecordingWithHttpInfo(accountId, callId, recordingId, transcribeRecording); + + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } /// @@ -185,11 +253,13 @@ public void TranscribeCallRecordingTest() [Fact] public void UpdateCallRecordingStateTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string callId = null; - //UpdateCallRecording updateCallRecording = null; - //instance.UpdateCallRecordingState(accountId, callId, updateCallRecording); + UpdateCallRecording updateCallRecording = new( + state: RecordingStateEnum.Paused + ); + + ApiResponse response = instance.UpdateCallRecordingStateWithHttpInfo(accountId, callId, updateCallRecording); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/StatisticsApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/StatisticsApiTests.cs index 5bcb1a94..226a3906 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/StatisticsApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/StatisticsApiTests.cs @@ -9,35 +9,34 @@ */ using System; -using System.IO; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using RestSharp; +using System.Net; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -// uncomment below to import models -//using Bandwidth.Standard.Model; +using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Api +namespace Bandwidth.Standard.Test.Unit.Api { /// - /// Class for testing StatisticsApi + /// StatisticsApi Unit Tests /// - /// - /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). - /// Please update the test case below to test the API endpoint. - /// public class StatisticsApiTests : IDisposable { - private StatisticsApi instance; + private readonly StatisticsApi instance; + + private readonly string accountId = Environment.GetEnvironmentVariable("BW_ACCOUNT_ID"); public StatisticsApiTests() { - instance = new StatisticsApi(); + Configuration configuration = new() + { + BasePath = "http://127.0.0.1:4010", + IgnoreOperationServers = true, + OAuthClientId = Environment.GetEnvironmentVariable("BW_CLIENT_ID"), + OAuthClientSecret = Environment.GetEnvironmentVariable("BW_CLIENT_SECRET") + }; + instance = new StatisticsApi(configuration); } public void Dispose() @@ -51,8 +50,7 @@ public void Dispose() [Fact] public void InstanceTest() { - // TODO uncomment below to test 'IsType' StatisticsApi - //Assert.IsType(instance); + Assert.IsType(instance); } /// @@ -61,10 +59,12 @@ public void InstanceTest() [Fact] public void GetStatisticsTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //var response = instance.GetStatistics(accountId); - //Assert.IsType(response); + ApiResponse response = instance.GetStatisticsWithHttpInfo(accountId); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType(response.Data.CurrentCallQueueSize); + Assert.IsType(response.Data.MaxCallQueueSize); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/TollFreeVerificationApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/TollFreeVerificationApiTests.cs index fc771ce3..72cf046a 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/TollFreeVerificationApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/TollFreeVerificationApiTests.cs @@ -9,35 +9,47 @@ */ using System; -using System.IO; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using RestSharp; +using System.Net; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -// uncomment below to import models -//using Bandwidth.Standard.Model; +using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Api +namespace Bandwidth.Standard.Test.Unit.Api { /// - /// Class for testing TollFreeVerificationApi + /// TollFreeVerificationApi Unit Tests /// - /// - /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). - /// Please update the test case below to test the API endpoint. - /// public class TollFreeVerificationApiTests : IDisposable { - private TollFreeVerificationApi instance; + private readonly TollFreeVerificationApi instance; + + private readonly string accountId = Environment.GetEnvironmentVariable("BW_ACCOUNT_ID"); + + private readonly string phoneNumber = "+18005551234"; + private readonly string subscriptionId = "test-id-1234"; + + private readonly WebhookSubscriptionRequestSchema webhookSubscriptionRequestSchema = new( + basicAuthentication: new TfvBasicAuthentication( + username: "username", + password: "password" + ), + callbackUrl: "https://example.com", + sharedSecretKey: "shared-secret-key" + ); public TollFreeVerificationApiTests() { - instance = new TollFreeVerificationApi(); + Configuration configuration = new() + { + BasePath = "http://127.0.0.1:4010", + IgnoreOperationServers = true, + OAuthClientId = Environment.GetEnvironmentVariable("BW_CLIENT_ID"), + OAuthClientSecret = Environment.GetEnvironmentVariable("BW_CLIENT_SECRET") + }; + instance = new TollFreeVerificationApi(configuration); } public void Dispose() @@ -51,8 +63,7 @@ public void Dispose() [Fact] public void InstanceTest() { - // TODO uncomment below to test 'IsType' TollFreeVerificationApi - //Assert.IsType(instance); + Assert.IsType(instance); } /// @@ -61,11 +72,19 @@ public void InstanceTest() [Fact] public void CreateWebhookSubscriptionTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //WebhookSubscriptionRequestSchema webhookSubscriptionRequestSchema = null; - //var response = instance.CreateWebhookSubscription(accountId, webhookSubscriptionRequestSchema); - //Assert.IsType(response); + ApiResponse response = instance.CreateWebhookSubscriptionWithHttpInfo(accountId, webhookSubscriptionRequestSchema); + + Assert.Equal(HttpStatusCode.Created, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType(response.Data.Id); + Assert.IsType(response.Data.AccountId); + Assert.IsType(response.Data.CallbackUrl); + Assert.IsType(response.Data.Type); + Assert.IsType(response.Data.BasicAuthentication); + Assert.IsType(response.Data.BasicAuthentication.Username); + Assert.IsType(response.Data.BasicAuthentication.Password); + Assert.IsType(response.Data.CreatedDate); + Assert.IsType(response.Data.ModifiedDate); } /// @@ -74,10 +93,9 @@ public void CreateWebhookSubscriptionTest() [Fact] public void DeleteVerificationRequestTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string phoneNumber = null; - //instance.DeleteVerificationRequest(accountId, phoneNumber); + ApiResponse response = instance.DeleteVerificationRequestWithHttpInfo(accountId, phoneNumber); + + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } /// @@ -86,10 +104,9 @@ public void DeleteVerificationRequestTest() [Fact] public void DeleteWebhookSubscriptionTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string id = null; - //instance.DeleteWebhookSubscription(accountId, id); + ApiResponse response = instance.DeleteWebhookSubscriptionWithHttpInfo(accountId, subscriptionId); + + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } /// @@ -98,11 +115,23 @@ public void DeleteWebhookSubscriptionTest() [Fact] public void GetTollFreeVerificationStatusTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string phoneNumber = null; - //var response = instance.GetTollFreeVerificationStatus(accountId, phoneNumber); - //Assert.IsType(response); + ApiResponse response = instance.GetTollFreeVerificationStatusWithHttpInfo(accountId, phoneNumber); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType(response.Data.PhoneNumber); + Assert.IsType(response.Data.Status); + Assert.IsType(response.Data.InternalTicketNumber); + Assert.IsType(response.Data.DeclineReasonDescription); + Assert.IsType(response.Data.DenialStatusCode); + Assert.IsType>(response.Data.AdditionalDenialReasons); + Assert.IsType(response.Data.ResubmitAllowed); + Assert.IsType(response.Data.CreatedDateTime); + Assert.IsType(response.Data.ModifiedDateTime); + Assert.IsType(response.Data.Submission); + Assert.IsType(response.Data.Blocked); + Assert.IsType(response.Data.BlockedReason); + Assert.IsType(response.Data.CvToken); } /// @@ -111,9 +140,10 @@ public void GetTollFreeVerificationStatusTest() [Fact] public void ListTollFreeUseCasesTest() { - // TODO uncomment below to test the method and replace null with proper value - //var response = instance.ListTollFreeUseCases(); - //Assert.IsType>(response); + ApiResponse> response = instance.ListTollFreeUseCasesWithHttpInfo(); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType>(response.Data); } /// @@ -122,10 +152,32 @@ public void ListTollFreeUseCasesTest() [Fact] public void ListWebhookSubscriptionsTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //var response = instance.ListWebhookSubscriptions(accountId); - //Assert.IsType(response); + ApiResponse response = instance.ListWebhookSubscriptionsWithHttpInfo(accountId); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType(response.Data.Links); + Assert.IsType(response.Data.Links.First); + Assert.IsType(response.Data.Links.Next); + Assert.IsType(response.Data.Links.Previous); + Assert.IsType(response.Data.Links.Last); + Assert.IsType>(response.Data.Errors); + Assert.IsType(response.Data.Errors[0].Code); + Assert.IsType(response.Data.Errors[0].Description); + Assert.IsType>(response.Data.Errors[0].TelephoneNumbers); + Assert.IsType(response.Data.Errors[0].TelephoneNumbers[0]); + Assert.IsType(response.Data.Errors[0].TelephoneNumbers[0].VarTelephoneNumber); + Assert.IsType>(response.Data.Data); + Assert.IsType(response.Data.Data[0]); + Assert.IsType(response.Data.Data[0].Id); + Assert.IsType(response.Data.Data[0].AccountId); + Assert.IsType(response.Data.Data[0].CallbackUrl); + Assert.IsType(response.Data.Data[0].Type); + Assert.IsType(response.Data.Data[0].BasicAuthentication); + Assert.IsType(response.Data.Data[0].BasicAuthentication.Username); + Assert.IsType(response.Data.Data[0].BasicAuthentication.Password); + Assert.IsType(response.Data.Data[0].CreatedDate); + Assert.IsType(response.Data.Data[0].ModifiedDate); } /// @@ -134,10 +186,49 @@ public void ListWebhookSubscriptionsTest() [Fact] public void RequestTollFreeVerificationTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //VerificationRequest verificationRequest = null; - //instance.RequestTollFreeVerification(accountId, verificationRequest); + VerificationRequest verificationRequest = new( + businessAddress: new Address( + name: "name", + addr1: "addr1", + addr2: "addr2", + city: "city", + state: "state", + zip: "zip", + url: "https://example.com" + ), + businessContact: new Contact( + firstName: "first-name", + lastName: "last-name", + email: "email@email.com", + phoneNumber: "+19195551234" + ), + messageVolume: 12, + phoneNumbers: new List { "+18005551234" }, + useCase: "useCase", + useCaseSummary: "useCaseSummary", + productionMessageContent: "productionMessageContent", + optInWorkflow: new OptInWorkflow( + description: "description", + imageUrls: new List { "https://example.com" }, + confirmationResponse: "confirmationResponse" + ), + additionalInformation: "additionalInformation", + isvReseller: "isvReseller", + privacyPolicyUrl: "privacyPolicyUrl", + termsAndConditionsUrl: "termsAndConditionsUrl", + businessDba: "businessDba", + businessRegistrationNumber: "businessRegistrationNumber", + businessRegistrationType: BusinessRegistrationTypeEnum.EIN, + businessEntityType: BusinessEntityTypeEnum.PRIVATEPROFIT, + businessRegistrationIssuingCountry: "USA", + helpMessageResponse: "helpMessageResponse", + ageGatedContent: true, + cvToken: "cvToken" + ); + + ApiResponse response = instance.RequestTollFreeVerificationWithHttpInfo(accountId, verificationRequest); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); } /// @@ -146,11 +237,13 @@ public void RequestTollFreeVerificationTest() [Fact] public void UpdateTollFreeVerificationRequestTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string phoneNumber = null; - //TfvSubmissionWrapper tfvSubmissionWrapper = null; - //instance.UpdateTollFreeVerificationRequest(accountId, phoneNumber, tfvSubmissionWrapper); + TfvSubmissionWrapper tfvSubmissionWrapper = new( + submission: null + ); + + ApiResponse response = instance.UpdateTollFreeVerificationRequestWithHttpInfo(accountId, phoneNumber, tfvSubmissionWrapper); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); } /// @@ -159,12 +252,19 @@ public void UpdateTollFreeVerificationRequestTest() [Fact] public void UpdateWebhookSubscriptionTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string id = null; - //WebhookSubscriptionRequestSchema webhookSubscriptionRequestSchema = null; - //var response = instance.UpdateWebhookSubscription(accountId, id, webhookSubscriptionRequestSchema); - //Assert.IsType(response); + ApiResponse response = instance.UpdateWebhookSubscriptionWithHttpInfo(accountId, subscriptionId, webhookSubscriptionRequestSchema); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.IsType(response.Data.Id); + Assert.IsType(response.Data.AccountId); + Assert.IsType(response.Data.CallbackUrl); + Assert.IsType(response.Data.Type); + Assert.IsType(response.Data.BasicAuthentication); + Assert.IsType(response.Data.BasicAuthentication.Username); + Assert.IsType(response.Data.BasicAuthentication.Password); + Assert.IsType(response.Data.CreatedDate); + Assert.IsType(response.Data.ModifiedDate); } } } diff --git a/src/Bandwidth.Standard.Test/Unit/Api/TranscriptionsApiTests.cs b/src/Bandwidth.Standard.Test/Unit/Api/TranscriptionsApiTests.cs index de8c1f54..ec73f8b1 100644 --- a/src/Bandwidth.Standard.Test/Unit/Api/TranscriptionsApiTests.cs +++ b/src/Bandwidth.Standard.Test/Unit/Api/TranscriptionsApiTests.cs @@ -9,35 +9,38 @@ */ using System; -using System.IO; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using RestSharp; +using System.Net; using Xunit; using Bandwidth.Standard.Client; using Bandwidth.Standard.Api; -// uncomment below to import models -//using Bandwidth.Standard.Model; +using Bandwidth.Standard.Model; -namespace Bandwidth.Standard.Test.Api +namespace Bandwidth.Standard.Test.Unit.Api { /// - /// Class for testing TranscriptionsApi + /// TranscriptionsApi Unit Tests /// - /// - /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). - /// Please update the test case below to test the API endpoint. - /// public class TranscriptionsApiTests : IDisposable { - private TranscriptionsApi instance; + private readonly TranscriptionsApi instance; + + private readonly string accountId = Environment.GetEnvironmentVariable("BW_ACCOUNT_ID"); + + private readonly string callId = "c-1234"; + private readonly string transcriptionId = "t-1234"; public TranscriptionsApiTests() { - instance = new TranscriptionsApi(); + Configuration configuration = new() + { + BasePath = "http://127.0.0.1:4010", + IgnoreOperationServers = true, + OAuthClientId = Environment.GetEnvironmentVariable("BW_CLIENT_ID"), + OAuthClientSecret = Environment.GetEnvironmentVariable("BW_CLIENT_SECRET") + }; + instance = new TranscriptionsApi(configuration); } public void Dispose() @@ -51,8 +54,7 @@ public void Dispose() [Fact] public void InstanceTest() { - // TODO uncomment below to test 'IsType' TranscriptionsApi - //Assert.IsType(instance); + Assert.IsType(instance); } /// @@ -61,11 +63,10 @@ public void InstanceTest() [Fact] public void DeleteRealTimeTranscriptionTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string callId = null; - //string transcriptionId = null; - //instance.DeleteRealTimeTranscription(accountId, callId, transcriptionId); + ApiResponse response = instance.DeleteRealTimeTranscriptionWithHttpInfo(accountId, callId, transcriptionId); + + // This is a bug in the API, it should return 204. VAPI-1863 should fix this. + Assert.Equal(HttpStatusCode.OK, response.StatusCode); } /// @@ -74,12 +75,19 @@ public void DeleteRealTimeTranscriptionTest() [Fact] public void GetRealTimeTranscriptionTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string callId = null; - //string transcriptionId = null; - //var response = instance.GetRealTimeTranscription(accountId, callId, transcriptionId); - //Assert.IsType(response); + ApiResponse response = instance.GetRealTimeTranscriptionWithHttpInfo(accountId, callId, transcriptionId); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data); + Assert.Equal(7, response.Data.AccountId.Length); + Assert.Equal(47, response.Data.CallId.Length); + Assert.IsType(response.Data.TranscriptionId); + Assert.IsType>(response.Data.Tracks); + Assert.IsType(response.Data.Tracks[0]); + Assert.IsType(response.Data.Tracks[0].DetectedLanguage); + Assert.IsType(response.Data.Tracks[0].Track); + Assert.IsType(response.Data.Tracks[0].Transcript); + Assert.IsType(response.Data.Tracks[0].Confidence); } /// @@ -88,11 +96,13 @@ public void GetRealTimeTranscriptionTest() [Fact] public void ListRealTimeTranscriptionsTest() { - // TODO uncomment below to test the method and replace null with proper value - //string accountId = null; - //string callId = null; - //var response = instance.ListRealTimeTranscriptions(accountId, callId); - //Assert.IsType>(response); + ApiResponse> response = instance.ListRealTimeTranscriptionsWithHttpInfo(accountId, callId); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.IsType(response.Data[0]); + Assert.IsType(response.Data[0].TranscriptionId); + Assert.IsType(response.Data[0].TranscriptionUrl); + Assert.IsType(response.Data[0].TranscriptionName); } } } From 4bcb279d1bf5dfea4f21ce52d9cf35fbfc43bc3c Mon Sep 17 00:00:00 2001 From: ckoegel Date: Mon, 6 Jul 2026 16:57:21 -0400 Subject: [PATCH 7/7] add dotnet 10 to matrix and run prism --- .github/workflows/test-pr.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index f3b39fb7..2c336e13 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -34,7 +34,7 @@ jobs: strategy: matrix: os: [windows-2022, windows-2025, ubuntu-22.04, ubuntu-24.04] - dotnet: [6.0.x, 7.0.x, 8.0.x] + dotnet: [6.0.x, 7.0.x, 8.0.x, 10.0.x] fail-fast: false steps: - name: Checkout @@ -50,4 +50,5 @@ jobs: OPERATING_SYSTEM: ${{ matrix.os }} DOTNET_VERSION: ${{ matrix.dotnet }} run: | - dotnet test src/Bandwidth.Standard.Test --filter DisplayName~Bandwidth.Standard.Test.Unit + npm install -g @stoplight/prism-cli + prism mock ./bandwidth.yml & dotnet test src/Bandwidth.Standard.Test --filter DisplayName~Bandwidth.Standard.Test.Unit