Skip to content

Commit 3861a3a

Browse files
authored
Merge pull request #84 from Bandwidth/SWI-6546
SWI-6546
2 parents 289c7d8 + 70829c6 commit 3861a3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+502
-596
lines changed

Bandwidth.Iris.Tests/ClientTests.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public void GetInstanceTest()
2929
[Fact]
3030
public void MakeGetRequestTest()
3131
{
32-
using (var server = new HttpServer(new RequestHandler {
32+
using (var server = new HttpServer(new RequestHandler
33+
{
3334
EstimatedMethod = "GET",
3435
EstimatedPathAndQuery = "/v1.0/test?test1=value1&test2=value2",
3536
EstimatedHeaders = new Dictionary<string, string>
@@ -75,7 +76,7 @@ public void MakeGetRequestTTest()
7576
{
7677
EstimatedMethod = "GET",
7778
EstimatedPathAndQuery = "/v1.0/test?test1=value1&test2=value2",
78-
ContentToSend = Helper.CreateXmlContent(new TestItem
79+
ContentToSend = Helper.CreateXmlContent(new TestItem
7980
{
8081
Name = "Name",
8182
Flag = true
@@ -141,7 +142,7 @@ public void MakePostRequestTTest()
141142
{
142143
EstimatedMethod = "POST",
143144
EstimatedPathAndQuery = "/v1.0/test",
144-
EstimatedContent = Helper.ToXmlString(new TestModel{Test = true}),
145+
EstimatedContent = Helper.ToXmlString(new TestModel { Test = true }),
145146
ContentToSend = Helper.CreateXmlContent(new TestItem
146147
{
147148
Name = "Name",
@@ -151,7 +152,7 @@ public void MakePostRequestTTest()
151152
{
152153
var client = Helper.CreateClient();
153154
{
154-
var result = client.MakePostRequest<TestItem>("test", new TestModel{ Test = true }).Result;
155+
var result = client.MakePostRequest<TestItem>("test", new TestModel { Test = true }).Result;
155156
if (server.Error != null) throw server.Error;
156157
Assert.Equal("Name", result.Name);
157158
Assert.True(result.Flag != null && result.Flag.Value);
@@ -183,7 +184,7 @@ public void AuthHeaderTest()
183184
using (var server = new HttpServer(new RequestHandler
184185
{
185186
EstimatedMethod = "GET",
186-
EstimatedHeaders = new Dictionary<string, string> { { "Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", Helper.UserName, Helper.Password)))} },
187+
EstimatedHeaders = new Dictionary<string, string> { { "Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", Helper.UserName, Helper.Password))) } },
187188
ContentToSend = Helper.CreateXmlContent(new SitesResponse())
188189
}))
189190
{
@@ -203,13 +204,13 @@ public void PutDataWithStreamTest()
203204
EstimatedMethod = "PUT",
204205
EstimatedPathAndQuery = "/v1.0/test",
205206
EstimatedContent = "hello",
206-
EstimatedHeaders = new Dictionary<string, string> {{"Content-Type", "media/type"}}
207+
EstimatedHeaders = new Dictionary<string, string> { { "Content-Type", "media/type" } }
207208
}))
208209
{
209210
var client = Helper.CreateClient();
210211
using (var stream = new MemoryStream(data))
211212
{
212-
client.SendData("test", stream, "media/type", "PUT", true).Wait();
213+
client.SendData("test", stream, "media/type", "PUT", true).Wait();
213214
if (server.Error != null) throw server.Error;
214215
}
215216
}
@@ -228,7 +229,7 @@ public void SendDataWithByteArrayTest()
228229
}))
229230
{
230231
var client = Helper.CreateClient();
231-
client.SendData("test", new MemoryStream( data), "media/type", "PUT", true).Wait();
232+
client.SendData("test", new MemoryStream(data), "media/type", "PUT", true).Wait();
232233
if (server.Error != null) throw server.Error;
233234
}
234235

@@ -361,7 +362,7 @@ public void Error3Test()
361362
catch (AggregateException ex)
362363
{
363364
var err = (AggregateException)ex.InnerExceptions.First();
364-
var list = (from e in err.InnerExceptions select (BandwidthIrisException) e).ToArray();
365+
var list = (from e in err.InnerExceptions select (BandwidthIrisException)e).ToArray();
365366
Assert.Equal("101", list[0].Code);
366367
Assert.Equal("Description1", list[0].Message);
367368
Assert.Equal("102", list[1].Code);

Bandwidth.Iris.Tests/Helper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static string ToXmlStringMinified(object data)
115115
}
116116
}
117117

118-
public static void SetEnvironmetVariables(string baseUrl = null)
118+
public static void SetEnvironmentVariables(string baseUrl = null)
119119
{
120120
Environment.SetEnvironmentVariable(Client.BandwidthApiUserName, UserName);
121121
Environment.SetEnvironmentVariable(Client.BandwidthApiPassword, Password);

Bandwidth.Iris.Tests/Models/AccountTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class AccountTests
1212
// [TestInitialize]
1313
public AccountTests()
1414
{
15-
Helper.SetEnvironmetVariables();
15+
Helper.SetEnvironmentVariables();
1616
}
1717

1818
[Fact]

Bandwidth.Iris.Tests/Models/AeuiTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class AeuiTests
1212
// [TestInitialize]
1313
public AeuiTests()
1414
{
15-
Helper.SetEnvironmetVariables();
15+
Helper.SetEnvironmentVariables();
1616
}
1717

1818
[Fact]

Bandwidth.Iris.Tests/Models/ApplicationTest.cs

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class ApplicationTest
1919
// [TestInitialize]
2020
public ApplicationTest()
2121
{
22-
Helper.SetEnvironmetVariables();
22+
Helper.SetEnvironmentVariables();
2323

2424
}
2525

@@ -55,7 +55,7 @@ public void TestApplicationProvisioningResponse()
5555
var actual = Helper.ToXmlStringMinified(apresponse);
5656

5757
//Linerize the XML
58-
XDocument doc = XDocument.Parse( TestXmlStrings.multiApplicationProvisionResponse );
58+
XDocument doc = XDocument.Parse(TestXmlStrings.multiApplicationProvisionResponse);
5959
var xmlExpected = doc.ToString(SaveOptions.DisableFormatting);
6060

6161

@@ -82,7 +82,7 @@ public void TestApplicationProvisioningResponse()
8282
};
8383

8484
actual = Helper.ToXmlStringMinified(apresponse);
85-
xmlExpected = XDocument.Parse( TestXmlStrings.singleApplicationProvisionResponse ).ToString(SaveOptions.DisableFormatting);
85+
xmlExpected = XDocument.Parse(TestXmlStrings.singleApplicationProvisionResponse).ToString(SaveOptions.DisableFormatting);
8686

8787
Assert.Equal(xmlExpected, actual);
8888

@@ -128,7 +128,7 @@ public void TestAssociatedSipPeersResponse()
128128
public void TestListApplications()
129129
{
130130

131-
string strResponse = XDocument.Parse(TestXmlStrings.multiApplicationProvisionResponse ).ToString(SaveOptions.DisableFormatting);
131+
string strResponse = XDocument.Parse(TestXmlStrings.multiApplicationProvisionResponse).ToString(SaveOptions.DisableFormatting);
132132

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

147-
Assert.Equal(r.ApplicationList.Length, 2);
147+
Assert.Equal(2, r.ApplicationList.Length);
148148

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

154154

155155
}
@@ -192,14 +192,14 @@ public void TestCreateApplication()
192192

193193
Assert.NotNull(r.Application);
194194

195-
Assert.Equal(r.Application.ApplicationId, "d3e418e9-1833-49c1-b6c7-ca1700f79586");
196-
Assert.Equal(r.Application.ServiceType, "Voice-V2");
197-
Assert.Equal(r.Application.AppName, "v1");
198-
Assert.Equal(r.Application.CallInitiatedCallbackUrl, "https://a.com");
199-
Assert.Equal(r.Application.CallStatusCallbackUrl, "https://b.com");
200-
Assert.Equal(r.Application.CallInitiatedMethod, "GET");
201-
Assert.Equal(r.Application.CallStatusMethod, "GET");
202-
Assert.Equal(r.Application.CallbackCreds.UserId, "login123");
195+
Assert.Equal("d3e418e9-1833-49c1-b6c7-ca1700f79586", r.Application.ApplicationId);
196+
Assert.Equal("Voice-V2", r.Application.ServiceType);
197+
Assert.Equal("v1", r.Application.AppName);
198+
Assert.Equal("https://a.com", r.Application.CallInitiatedCallbackUrl);
199+
Assert.Equal("https://b.com", r.Application.CallStatusCallbackUrl);
200+
Assert.Equal("GET", r.Application.CallInitiatedMethod);
201+
Assert.Equal("GET", r.Application.CallStatusMethod);
202+
Assert.Equal("login123", r.Application.CallbackCreds.UserId);
203203

204204

205205
}
@@ -230,14 +230,14 @@ public void TestGetApplication()
230230

231231
Assert.NotNull(r.Application);
232232

233-
Assert.Equal(r.Application.ApplicationId, "d3e418e9-1833-49c1-b6c7-ca1700f79586");
234-
Assert.Equal(r.Application.ServiceType, "Voice-V2");
235-
Assert.Equal(r.Application.AppName, "v1");
236-
Assert.Equal(r.Application.CallInitiatedCallbackUrl, "https://a.com");
237-
Assert.Equal(r.Application.CallStatusCallbackUrl, "https://b.com");
238-
Assert.Equal(r.Application.CallInitiatedMethod, "GET");
239-
Assert.Equal(r.Application.CallStatusMethod, "GET");
240-
Assert.Equal(r.Application.CallbackCreds.UserId, "login123");
233+
Assert.Equal("d3e418e9-1833-49c1-b6c7-ca1700f79586", r.Application.ApplicationId);
234+
Assert.Equal("Voice-V2", r.Application.ServiceType);
235+
Assert.Equal("v1", r.Application.AppName);
236+
Assert.Equal("https://a.com", r.Application.CallInitiatedCallbackUrl);
237+
Assert.Equal("https://b.com", r.Application.CallStatusCallbackUrl);
238+
Assert.Equal("GET", r.Application.CallInitiatedMethod);
239+
Assert.Equal("GET", r.Application.CallStatusMethod);
240+
Assert.Equal("login123", r.Application.CallbackCreds.UserId);
241241

242242

243243
}
@@ -272,14 +272,14 @@ public void TestFullUpdateApplication()
272272

273273
Assert.NotNull(r.Application);
274274

275-
Assert.Equal(r.Application.ApplicationId, "d3e418e9-1833-49c1-b6c7-ca1700f79586");
276-
Assert.Equal(r.Application.ServiceType, "Voice-V2");
277-
Assert.Equal(r.Application.AppName, "v1");
278-
Assert.Equal(r.Application.CallInitiatedCallbackUrl, "https://a.com");
279-
Assert.Equal(r.Application.CallStatusCallbackUrl, "https://b.com");
280-
Assert.Equal(r.Application.CallInitiatedMethod, "GET");
281-
Assert.Equal(r.Application.CallStatusMethod, "GET");
282-
Assert.Equal(r.Application.CallbackCreds.UserId, "login123");
275+
Assert.Equal("d3e418e9-1833-49c1-b6c7-ca1700f79586", r.Application.ApplicationId);
276+
Assert.Equal("Voice-V2", r.Application.ServiceType);
277+
Assert.Equal("v1", r.Application.AppName);
278+
Assert.Equal("https://a.com", r.Application.CallInitiatedCallbackUrl);
279+
Assert.Equal("https://b.com", r.Application.CallStatusCallbackUrl);
280+
Assert.Equal("GET", r.Application.CallInitiatedMethod);
281+
Assert.Equal("GET", r.Application.CallStatusMethod);
282+
Assert.Equal("login123", r.Application.CallbackCreds.UserId);
283283

284284

285285
}
@@ -314,14 +314,14 @@ public void TestPartialUpdateApplication()
314314

315315
Assert.NotNull(r.Application);
316316

317-
Assert.Equal(r.Application.ApplicationId, "d3e418e9-1833-49c1-b6c7-ca1700f79586");
318-
Assert.Equal(r.Application.ServiceType, "Voice-V2");
319-
Assert.Equal(r.Application.AppName, "v1");
320-
Assert.Equal(r.Application.CallInitiatedCallbackUrl, "https://a.com");
321-
Assert.Equal(r.Application.CallStatusCallbackUrl, "https://b.com");
322-
Assert.Equal(r.Application.CallInitiatedMethod, "GET");
323-
Assert.Equal(r.Application.CallStatusMethod, "GET");
324-
Assert.Equal(r.Application.CallbackCreds.UserId, "login123");
317+
Assert.Equal("d3e418e9-1833-49c1-b6c7-ca1700f79586", r.Application.ApplicationId);
318+
Assert.Equal("Voice-V2", r.Application.ServiceType);
319+
Assert.Equal("v1", r.Application.AppName);
320+
Assert.Equal("https://a.com", r.Application.CallInitiatedCallbackUrl);
321+
Assert.Equal("https://b.com", r.Application.CallStatusCallbackUrl);
322+
Assert.Equal("GET", r.Application.CallInitiatedMethod);
323+
Assert.Equal("GET", r.Application.CallStatusMethod);
324+
Assert.Equal("login123", r.Application.CallbackCreds.UserId);
325325

326326

327327
}
@@ -374,11 +374,11 @@ public void TestGetAssociatesSipPeers()
374374

375375
Assert.NotNull(r.AssociatedSipPeers);
376376

377-
Assert.Equal(r.AssociatedSipPeers.Length, 2);
378-
Assert.Equal(r.AssociatedSipPeers[0].SiteId, "13651");
379-
Assert.Equal(r.AssociatedSipPeers[0].SiteName, "Prod Sub-account");
380-
Assert.Equal(r.AssociatedSipPeers[0].PeerId, "540341");
381-
Assert.Equal(r.AssociatedSipPeers[0].PeerName, "Prod");
377+
Assert.Equal(2, r.AssociatedSipPeers.Length);
378+
Assert.Equal("13651", r.AssociatedSipPeers[0].SiteId);
379+
Assert.Equal("Prod Sub-account", r.AssociatedSipPeers[0].SiteName);
380+
Assert.Equal("540341", r.AssociatedSipPeers[0].PeerId);
381+
Assert.Equal("Prod", r.AssociatedSipPeers[0].PeerName);
382382

383383

384384

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

401402
{
@@ -405,13 +406,14 @@ public void TestGetAssociatesSipPeers400()
405406
{
406407
var r = t.Result;
407408
Assert.True(false, "The exception was not thrown");
408-
} catch (AggregateException e)
409+
}
410+
catch (AggregateException e)
409411
{
410-
e.Handle( ex =>
412+
e.Handle(ex =>
411413
{
412-
if(ex is BandwidthIrisException)
414+
if (ex is BandwidthIrisException)
413415
{
414-
Assert.Equal(ex.Message, " Current 1 Account have no Catapult association ");
416+
Assert.Equal(" Current 1 Account have no Catapult association ", ex.Message);
415417
return true;
416418
}
417419
return true;
@@ -431,7 +433,8 @@ public void TestGetAssociatesSipPeers404()
431433
{
432434
EstimatedMethod = "GET",
433435
EstimatedPathAndQuery = $"/v1.0/accounts/{Helper.AccountId}/applications/{applicationId}/associatedsippeers",
434-
ContentToSend = new StringContent(TestXmlStrings.associatedSipPeerResponse404, Encoding.UTF8, "application/xml")
436+
ContentToSend = new StringContent(TestXmlStrings.associatedSipPeerResponse404, Encoding.UTF8, "application/xml"),
437+
StatusCodeToSend = 404
435438
}))
436439

437440
{
@@ -448,7 +451,7 @@ public void TestGetAssociatesSipPeers404()
448451
{
449452
if (ex is BandwidthIrisException)
450453
{
451-
Assert.Equal(ex.Message, " Application with id 'non_existing' not found ");
454+
Assert.Equal(" Application with id 'non_existing' not found ", ex.Message);
452455
return true;
453456
}
454457
return true;

Bandwidth.Iris.Tests/Models/AvailableNpaNxxTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class AvailableNpaNxxTests
1010
// [TestInitialize]
1111
public AvailableNpaNxxTests()
1212
{
13-
Helper.SetEnvironmetVariables();
13+
Helper.SetEnvironmentVariables();
1414
}
1515

1616
[Fact]

Bandwidth.Iris.Tests/Models/AvailableNumbersTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class AvailableNumbersTests
1212
// [TestInitialize]
1313
public AvailableNumbersTests()
1414
{
15-
Helper.SetEnvironmetVariables();
15+
Helper.SetEnvironmentVariables();
1616
}
1717

1818
[Fact]
@@ -25,7 +25,7 @@ public void ListTest()
2525
ContentToSend = Helper.CreateXmlContent(new AvailableNumbersResult
2626
{
2727
ResultCount = 2,
28-
TelephoneNumberList = new[] { "1111", "2222"}
28+
TelephoneNumberList = new[] { "1111", "2222" }
2929
})
3030
}))
3131
{

Bandwidth.Iris.Tests/Models/CityTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class CityTests
1212
// [TestInitialize]
1313
public CityTests()
1414
{
15-
Helper.SetEnvironmetVariables();
15+
Helper.SetEnvironmentVariables();
1616
}
1717

1818
[Fact]

Bandwidth.Iris.Tests/Models/CoveredRateCenterTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class RateCenterTests
1212
// [TestInitialize]
1313
public RateCenterTests()
1414
{
15-
Helper.SetEnvironmetVariables();
15+
Helper.SetEnvironmentVariables();
1616
}
1717

1818
[Fact]
@@ -31,7 +31,7 @@ public void ListTest()
3131
{"state", "NC"}
3232
}).Result;
3333
if (server.Error != null) throw server.Error;
34-
Assert.Equal(1, result.Length);
34+
Assert.Single(result);
3535
Assert.Equal("ACME", result[0].Abbreviation);
3636
Assert.Equal("ACME", result[0].Name);
3737
}
@@ -52,7 +52,7 @@ public void ListWithDefaultClientTest()
5252
{"state", "NC"}
5353
}).Result;
5454
if (server.Error != null) throw server.Error;
55-
Assert.Equal(1, result.Length);
55+
Assert.Single(result);
5656
Assert.Equal("ACME", result[0].Abbreviation);
5757
Assert.Equal("ACME", result[0].Name);
5858
}

0 commit comments

Comments
 (0)