Skip to content

Commit

Permalink
Merge pull request #84 from Bandwidth/SWI-6546
Browse files Browse the repository at this point in the history
SWI-6546
  • Loading branch information
ajrice6713 authored Nov 14, 2024
2 parents 289c7d8 + 70829c6 commit 3861a3a
Show file tree
Hide file tree
Showing 57 changed files with 502 additions and 596 deletions.
19 changes: 10 additions & 9 deletions Bandwidth.Iris.Tests/ClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public void GetInstanceTest()
[Fact]
public void MakeGetRequestTest()
{
using (var server = new HttpServer(new RequestHandler {
using (var server = new HttpServer(new RequestHandler
{
EstimatedMethod = "GET",
EstimatedPathAndQuery = "/v1.0/test?test1=value1&test2=value2",
EstimatedHeaders = new Dictionary<string, string>
Expand Down Expand Up @@ -75,7 +76,7 @@ public void MakeGetRequestTTest()
{
EstimatedMethod = "GET",
EstimatedPathAndQuery = "/v1.0/test?test1=value1&test2=value2",
ContentToSend = Helper.CreateXmlContent(new TestItem
ContentToSend = Helper.CreateXmlContent(new TestItem
{
Name = "Name",
Flag = true
Expand Down Expand Up @@ -141,7 +142,7 @@ public void MakePostRequestTTest()
{
EstimatedMethod = "POST",
EstimatedPathAndQuery = "/v1.0/test",
EstimatedContent = Helper.ToXmlString(new TestModel{Test = true}),
EstimatedContent = Helper.ToXmlString(new TestModel { Test = true }),
ContentToSend = Helper.CreateXmlContent(new TestItem
{
Name = "Name",
Expand All @@ -151,7 +152,7 @@ public void MakePostRequestTTest()
{
var client = Helper.CreateClient();
{
var result = client.MakePostRequest<TestItem>("test", new TestModel{ Test = true }).Result;
var result = client.MakePostRequest<TestItem>("test", new TestModel { Test = true }).Result;
if (server.Error != null) throw server.Error;
Assert.Equal("Name", result.Name);
Assert.True(result.Flag != null && result.Flag.Value);
Expand Down Expand Up @@ -183,7 +184,7 @@ public void AuthHeaderTest()
using (var server = new HttpServer(new RequestHandler
{
EstimatedMethod = "GET",
EstimatedHeaders = new Dictionary<string, string> { { "Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", Helper.UserName, Helper.Password)))} },
EstimatedHeaders = new Dictionary<string, string> { { "Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", Helper.UserName, Helper.Password))) } },
ContentToSend = Helper.CreateXmlContent(new SitesResponse())
}))
{
Expand All @@ -203,13 +204,13 @@ public void PutDataWithStreamTest()
EstimatedMethod = "PUT",
EstimatedPathAndQuery = "/v1.0/test",
EstimatedContent = "hello",
EstimatedHeaders = new Dictionary<string, string> {{"Content-Type", "media/type"}}
EstimatedHeaders = new Dictionary<string, string> { { "Content-Type", "media/type" } }
}))
{
var client = Helper.CreateClient();
using (var stream = new MemoryStream(data))
{
client.SendData("test", stream, "media/type", "PUT", true).Wait();
client.SendData("test", stream, "media/type", "PUT", true).Wait();
if (server.Error != null) throw server.Error;
}
}
Expand All @@ -228,7 +229,7 @@ public void SendDataWithByteArrayTest()
}))
{
var client = Helper.CreateClient();
client.SendData("test", new MemoryStream( data), "media/type", "PUT", true).Wait();
client.SendData("test", new MemoryStream(data), "media/type", "PUT", true).Wait();
if (server.Error != null) throw server.Error;
}

Expand Down Expand Up @@ -361,7 +362,7 @@ public void Error3Test()
catch (AggregateException ex)
{
var err = (AggregateException)ex.InnerExceptions.First();
var list = (from e in err.InnerExceptions select (BandwidthIrisException) e).ToArray();
var list = (from e in err.InnerExceptions select (BandwidthIrisException)e).ToArray();
Assert.Equal("101", list[0].Code);
Assert.Equal("Description1", list[0].Message);
Assert.Equal("102", list[1].Code);
Expand Down
2 changes: 1 addition & 1 deletion Bandwidth.Iris.Tests/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static string ToXmlStringMinified(object data)
}
}

public static void SetEnvironmetVariables(string baseUrl = null)
public static void SetEnvironmentVariables(string baseUrl = null)
{
Environment.SetEnvironmentVariable(Client.BandwidthApiUserName, UserName);
Environment.SetEnvironmentVariable(Client.BandwidthApiPassword, Password);
Expand Down
2 changes: 1 addition & 1 deletion Bandwidth.Iris.Tests/Models/AccountTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AccountTests
// [TestInitialize]
public AccountTests()
{
Helper.SetEnvironmetVariables();
Helper.SetEnvironmentVariables();
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion Bandwidth.Iris.Tests/Models/AeuiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AeuiTests
// [TestInitialize]
public AeuiTests()
{
Helper.SetEnvironmetVariables();
Helper.SetEnvironmentVariables();
}

[Fact]
Expand Down
109 changes: 56 additions & 53 deletions Bandwidth.Iris.Tests/Models/ApplicationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ApplicationTest
// [TestInitialize]
public ApplicationTest()
{
Helper.SetEnvironmetVariables();
Helper.SetEnvironmentVariables();

}

Expand Down Expand Up @@ -55,7 +55,7 @@ public void TestApplicationProvisioningResponse()
var actual = Helper.ToXmlStringMinified(apresponse);

//Linerize the XML
XDocument doc = XDocument.Parse( TestXmlStrings.multiApplicationProvisionResponse );
XDocument doc = XDocument.Parse(TestXmlStrings.multiApplicationProvisionResponse);
var xmlExpected = doc.ToString(SaveOptions.DisableFormatting);


Expand All @@ -82,7 +82,7 @@ public void TestApplicationProvisioningResponse()
};

actual = Helper.ToXmlStringMinified(apresponse);
xmlExpected = XDocument.Parse( TestXmlStrings.singleApplicationProvisionResponse ).ToString(SaveOptions.DisableFormatting);
xmlExpected = XDocument.Parse(TestXmlStrings.singleApplicationProvisionResponse).ToString(SaveOptions.DisableFormatting);

Assert.Equal(xmlExpected, actual);

Expand Down Expand Up @@ -128,7 +128,7 @@ public void TestAssociatedSipPeersResponse()
public void TestListApplications()
{

string strResponse = XDocument.Parse(TestXmlStrings.multiApplicationProvisionResponse ).ToString(SaveOptions.DisableFormatting);
string strResponse = XDocument.Parse(TestXmlStrings.multiApplicationProvisionResponse).ToString(SaveOptions.DisableFormatting);

using (var server = new HttpServer(new RequestHandler
{
Expand All @@ -144,12 +144,12 @@ public void TestListApplications()
var r = t.Result;
if (server.Error != null) throw server.Error;

Assert.Equal(r.ApplicationList.Length, 2);
Assert.Equal(2, r.ApplicationList.Length);

Assert.Equal(r.ApplicationList[0].ApplicationId, "2cfcb382-161c-46d4-8c67-87ca09a72c85");
Assert.Equal(r.ApplicationList[0].ServiceType, "Messaging-V2");
Assert.Equal(r.ApplicationList[0].AppName, "app1");
Assert.Equal(r.ApplicationList[0].MsgCallbackUrl, "http://a.com");
Assert.Equal("2cfcb382-161c-46d4-8c67-87ca09a72c85", r.ApplicationList[0].ApplicationId);
Assert.Equal("Messaging-V2", r.ApplicationList[0].ServiceType);
Assert.Equal("app1", r.ApplicationList[0].AppName);
Assert.Equal("http://a.com", r.ApplicationList[0].MsgCallbackUrl);


}
Expand Down Expand Up @@ -192,14 +192,14 @@ public void TestCreateApplication()

Assert.NotNull(r.Application);

Assert.Equal(r.Application.ApplicationId, "d3e418e9-1833-49c1-b6c7-ca1700f79586");
Assert.Equal(r.Application.ServiceType, "Voice-V2");
Assert.Equal(r.Application.AppName, "v1");
Assert.Equal(r.Application.CallInitiatedCallbackUrl, "https://a.com");
Assert.Equal(r.Application.CallStatusCallbackUrl, "https://b.com");
Assert.Equal(r.Application.CallInitiatedMethod, "GET");
Assert.Equal(r.Application.CallStatusMethod, "GET");
Assert.Equal(r.Application.CallbackCreds.UserId, "login123");
Assert.Equal("d3e418e9-1833-49c1-b6c7-ca1700f79586", r.Application.ApplicationId);
Assert.Equal("Voice-V2", r.Application.ServiceType);
Assert.Equal("v1", r.Application.AppName);
Assert.Equal("https://a.com", r.Application.CallInitiatedCallbackUrl);
Assert.Equal("https://b.com", r.Application.CallStatusCallbackUrl);
Assert.Equal("GET", r.Application.CallInitiatedMethod);
Assert.Equal("GET", r.Application.CallStatusMethod);
Assert.Equal("login123", r.Application.CallbackCreds.UserId);


}
Expand Down Expand Up @@ -230,14 +230,14 @@ public void TestGetApplication()

Assert.NotNull(r.Application);

Assert.Equal(r.Application.ApplicationId, "d3e418e9-1833-49c1-b6c7-ca1700f79586");
Assert.Equal(r.Application.ServiceType, "Voice-V2");
Assert.Equal(r.Application.AppName, "v1");
Assert.Equal(r.Application.CallInitiatedCallbackUrl, "https://a.com");
Assert.Equal(r.Application.CallStatusCallbackUrl, "https://b.com");
Assert.Equal(r.Application.CallInitiatedMethod, "GET");
Assert.Equal(r.Application.CallStatusMethod, "GET");
Assert.Equal(r.Application.CallbackCreds.UserId, "login123");
Assert.Equal("d3e418e9-1833-49c1-b6c7-ca1700f79586", r.Application.ApplicationId);
Assert.Equal("Voice-V2", r.Application.ServiceType);
Assert.Equal("v1", r.Application.AppName);
Assert.Equal("https://a.com", r.Application.CallInitiatedCallbackUrl);
Assert.Equal("https://b.com", r.Application.CallStatusCallbackUrl);
Assert.Equal("GET", r.Application.CallInitiatedMethod);
Assert.Equal("GET", r.Application.CallStatusMethod);
Assert.Equal("login123", r.Application.CallbackCreds.UserId);


}
Expand Down Expand Up @@ -272,14 +272,14 @@ public void TestFullUpdateApplication()

Assert.NotNull(r.Application);

Assert.Equal(r.Application.ApplicationId, "d3e418e9-1833-49c1-b6c7-ca1700f79586");
Assert.Equal(r.Application.ServiceType, "Voice-V2");
Assert.Equal(r.Application.AppName, "v1");
Assert.Equal(r.Application.CallInitiatedCallbackUrl, "https://a.com");
Assert.Equal(r.Application.CallStatusCallbackUrl, "https://b.com");
Assert.Equal(r.Application.CallInitiatedMethod, "GET");
Assert.Equal(r.Application.CallStatusMethod, "GET");
Assert.Equal(r.Application.CallbackCreds.UserId, "login123");
Assert.Equal("d3e418e9-1833-49c1-b6c7-ca1700f79586", r.Application.ApplicationId);
Assert.Equal("Voice-V2", r.Application.ServiceType);
Assert.Equal("v1", r.Application.AppName);
Assert.Equal("https://a.com", r.Application.CallInitiatedCallbackUrl);
Assert.Equal("https://b.com", r.Application.CallStatusCallbackUrl);
Assert.Equal("GET", r.Application.CallInitiatedMethod);
Assert.Equal("GET", r.Application.CallStatusMethod);
Assert.Equal("login123", r.Application.CallbackCreds.UserId);


}
Expand Down Expand Up @@ -314,14 +314,14 @@ public void TestPartialUpdateApplication()

Assert.NotNull(r.Application);

Assert.Equal(r.Application.ApplicationId, "d3e418e9-1833-49c1-b6c7-ca1700f79586");
Assert.Equal(r.Application.ServiceType, "Voice-V2");
Assert.Equal(r.Application.AppName, "v1");
Assert.Equal(r.Application.CallInitiatedCallbackUrl, "https://a.com");
Assert.Equal(r.Application.CallStatusCallbackUrl, "https://b.com");
Assert.Equal(r.Application.CallInitiatedMethod, "GET");
Assert.Equal(r.Application.CallStatusMethod, "GET");
Assert.Equal(r.Application.CallbackCreds.UserId, "login123");
Assert.Equal("d3e418e9-1833-49c1-b6c7-ca1700f79586", r.Application.ApplicationId);
Assert.Equal("Voice-V2", r.Application.ServiceType);
Assert.Equal("v1", r.Application.AppName);
Assert.Equal("https://a.com", r.Application.CallInitiatedCallbackUrl);
Assert.Equal("https://b.com", r.Application.CallStatusCallbackUrl);
Assert.Equal("GET", r.Application.CallInitiatedMethod);
Assert.Equal("GET", r.Application.CallStatusMethod);
Assert.Equal("login123", r.Application.CallbackCreds.UserId);


}
Expand Down Expand Up @@ -374,11 +374,11 @@ public void TestGetAssociatesSipPeers()

Assert.NotNull(r.AssociatedSipPeers);

Assert.Equal(r.AssociatedSipPeers.Length, 2);
Assert.Equal(r.AssociatedSipPeers[0].SiteId, "13651");
Assert.Equal(r.AssociatedSipPeers[0].SiteName, "Prod Sub-account");
Assert.Equal(r.AssociatedSipPeers[0].PeerId, "540341");
Assert.Equal(r.AssociatedSipPeers[0].PeerName, "Prod");
Assert.Equal(2, r.AssociatedSipPeers.Length);
Assert.Equal("13651", r.AssociatedSipPeers[0].SiteId);
Assert.Equal("Prod Sub-account", r.AssociatedSipPeers[0].SiteName);
Assert.Equal("540341", r.AssociatedSipPeers[0].PeerId);
Assert.Equal("Prod", r.AssociatedSipPeers[0].PeerName);



Expand All @@ -395,7 +395,8 @@ public void TestGetAssociatesSipPeers400()
{
EstimatedMethod = "GET",
EstimatedPathAndQuery = $"/v1.0/accounts/{Helper.AccountId}/applications/{applicationId}/associatedsippeers",
ContentToSend = new StringContent(TestXmlStrings.associatedSipPeerResponse400, Encoding.UTF8, "application/xml")
ContentToSend = new StringContent(TestXmlStrings.associatedSipPeerResponse400, Encoding.UTF8, "application/xml"),
StatusCodeToSend = 400
}))

{
Expand All @@ -405,13 +406,14 @@ public void TestGetAssociatesSipPeers400()
{
var r = t.Result;
Assert.True(false, "The exception was not thrown");
} catch (AggregateException e)
}
catch (AggregateException e)
{
e.Handle( ex =>
e.Handle(ex =>
{
if(ex is BandwidthIrisException)
if (ex is BandwidthIrisException)
{
Assert.Equal(ex.Message, " Current 1 Account have no Catapult association ");
Assert.Equal(" Current 1 Account have no Catapult association ", ex.Message);
return true;
}
return true;
Expand All @@ -431,7 +433,8 @@ public void TestGetAssociatesSipPeers404()
{
EstimatedMethod = "GET",
EstimatedPathAndQuery = $"/v1.0/accounts/{Helper.AccountId}/applications/{applicationId}/associatedsippeers",
ContentToSend = new StringContent(TestXmlStrings.associatedSipPeerResponse404, Encoding.UTF8, "application/xml")
ContentToSend = new StringContent(TestXmlStrings.associatedSipPeerResponse404, Encoding.UTF8, "application/xml"),
StatusCodeToSend = 404
}))

{
Expand All @@ -448,7 +451,7 @@ public void TestGetAssociatesSipPeers404()
{
if (ex is BandwidthIrisException)
{
Assert.Equal(ex.Message, " Application with id 'non_existing' not found ");
Assert.Equal(" Application with id 'non_existing' not found ", ex.Message);
return true;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion Bandwidth.Iris.Tests/Models/AvailableNpaNxxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class AvailableNpaNxxTests
// [TestInitialize]
public AvailableNpaNxxTests()
{
Helper.SetEnvironmetVariables();
Helper.SetEnvironmentVariables();
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions Bandwidth.Iris.Tests/Models/AvailableNumbersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AvailableNumbersTests
// [TestInitialize]
public AvailableNumbersTests()
{
Helper.SetEnvironmetVariables();
Helper.SetEnvironmentVariables();
}

[Fact]
Expand All @@ -25,7 +25,7 @@ public void ListTest()
ContentToSend = Helper.CreateXmlContent(new AvailableNumbersResult
{
ResultCount = 2,
TelephoneNumberList = new[] { "1111", "2222"}
TelephoneNumberList = new[] { "1111", "2222" }
})
}))
{
Expand Down
2 changes: 1 addition & 1 deletion Bandwidth.Iris.Tests/Models/CityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class CityTests
// [TestInitialize]
public CityTests()
{
Helper.SetEnvironmetVariables();
Helper.SetEnvironmentVariables();
}

[Fact]
Expand Down
6 changes: 3 additions & 3 deletions Bandwidth.Iris.Tests/Models/CoveredRateCenterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class RateCenterTests
// [TestInitialize]
public RateCenterTests()
{
Helper.SetEnvironmetVariables();
Helper.SetEnvironmentVariables();
}

[Fact]
Expand All @@ -31,7 +31,7 @@ public void ListTest()
{"state", "NC"}
}).Result;
if (server.Error != null) throw server.Error;
Assert.Equal(1, result.Length);
Assert.Single(result);
Assert.Equal("ACME", result[0].Abbreviation);
Assert.Equal("ACME", result[0].Name);
}
Expand All @@ -52,7 +52,7 @@ public void ListWithDefaultClientTest()
{"state", "NC"}
}).Result;
if (server.Error != null) throw server.Error;
Assert.Equal(1, result.Length);
Assert.Single(result);
Assert.Equal("ACME", result[0].Abbreviation);
Assert.Equal("ACME", result[0].Name);
}
Expand Down
Loading

0 comments on commit 3861a3a

Please sign in to comment.