public void TestListNoError() { using (var server = new HttpServer(new RequestHandler { EstimatedMethod = "GET", EstimatedPathAndQuery = $"/v1.0/accounts/{Helper.AccountId}/tnoptions?status=9199918388", ContentToSend = new StringContent(TestXmlStrings.listTnOptionsNoError, Encoding.UTF8, "application/xml") })) { var client = Helper.CreateClient(); TnOptionOrders result = null; try { result = TnOptions.List(client, new Dictionary <string, Object> { { "status", "9199918388" } }).Result; } catch (Exception ex) { Assert.IsNull(ex, "No Error should be thrown"); } if (server.Error != null) { throw server.Error; } Assert.IsNotNull(result); Assert.AreEqual(2, result.TotalCount); Assert.AreEqual(2, result.TnOptionOrderList.Count); Assert.AreEqual("14", result.TnOptionOrderList[0].AccountId); Assert.AreEqual("2016-01-15T12:01:14.324Z", result.TnOptionOrderList[0].OrderCreateDate); Assert.AreEqual("jbm", result.TnOptionOrderList[0].CreatedByUser); Assert.AreEqual("ddbdc72e-dc27-490c-904e-d0c11291b095", result.TnOptionOrderList[0].OrderId); Assert.AreEqual("2016-01-15T12:01:14.363Z", result.TnOptionOrderList[0].LastModifiedDate); Assert.AreEqual("FAILED", result.TnOptionOrderList[0].ProcessingStatus); Assert.AreEqual(2, result.TnOptionOrderList[0].TnOptionGroups.Count); } }
public void TestList() { using (var server = new HttpServer(new RequestHandler { EstimatedMethod = "GET", EstimatedPathAndQuery = $"/v1.0/accounts/{Helper.AccountId}/tnoptions?status=9199918388", ContentToSend = new StringContent(TestXmlStrings.listTnOptions, Encoding.UTF8, "application/xml") })) { var client = Helper.CreateClient(); TnOptionOrders result = null; try { result = TnOptions.List(client, new Dictionary <string, Object> { { "status", "9199918388" } }).Result; throw new Exception("Should have found error"); } catch (Exception ex) { Assert.IsNotNull(ex); if (ex.InnerException is BandwidthIrisException) { var exInner = (BandwidthIrisException)ex.InnerException; Console.WriteLine(exInner.Message); //"Telephone number is not available" Console.WriteLine(exInner.Body); } } if (server.Error != null) { throw server.Error; } Assert.IsNull(result); } }