예제 #1
0
        public void CheckWithXmlTest()
        {
            var request = new NumberPortabilityRequest
            {
                TnList = new[] { "1111", "2222", "3333" }
            };

            using (var server = new HttpServer(new RequestHandler
            {
                EstimatedMethod = "POST",
                EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/lnpchecker?fullCheck=true", Helper.AccountId),
                EstimatedContent = Helper.ToXmlString(request),
                ContentToSend = new StringContent(TestXmlStrings.LnpCheckResponse, Encoding.UTF8, "application/xml")
            }))
            {
                var client = Helper.CreateClient();
                var result = LnpChecker.Check(client, new[] { "1111", "2222", "3333" }, true).Result;
                if (server.Error != null)
                {
                    throw server.Error;
                }
                CollectionAssert.AreEqual(new[] { "9195551212", "9195551213" }, result.PortableNumbers);
                Assert.AreEqual("NC", result.SupportedRateCenters[0].State);
                CollectionAssert.AreEqual(new[] { "9195551212", "9195551213" }, result.SupportedLosingCarriers.LosingCarrierTnList.TnList);
            }
        }
예제 #2
0
        public void CheckThrowsErrorTest()
        {
            var request = new NumberPortabilityRequest
            {
                TnList = new[] { "1111" }
            };
            var response = new BandwidthIrisException(
                "170",
                "error thrown",
                System.Net.HttpStatusCode.ExpectationFailed
                );

            using (var server = new HttpServer(new RequestHandler
            {
                EstimatedMethod = "POST",
                EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/lnpchecker?fullCheck=true", Helper.AccountId),
                EstimatedContent = Helper.ToXmlString(request),
                ContentToSend = new StringContent("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><NumberPortabilityResponse><PortableNumbers><Tn>9192202164</Tn><Tn>9197891146</Tn></PortableNumbers><PortabilityErrors><Error><Code>7331</Code><Description>Rate Center Not Present in Bandwidth Dashboard</Description><TelephoneNumbers><Tn>5555555555</Tn></TelephoneNumbers></Error></PortabilityErrors><SupportedRateCenters><RateCenterGroup><RateCenter>DURHAM</RateCenter><City>DURHAM</City><State>NC</State><LATA>426</LATA><Tiers><Tier>0</Tier></Tiers><TnList><Tn>9192202164</Tn></TnList></RateCenterGroup><RateCenterGroup><RateCenter>RALEIGH</RateCenter><City>RALEIGH</City><State>NC</State><LATA>426</LATA><Tiers><Tier>0</Tier></Tiers><TnList><Tn>9197891146</Tn></TnList></RateCenterGroup></SupportedRateCenters><UnsupportedRateCenters/></NumberPortabilityResponse>", Encoding.UTF8, "application/xml")
            }))
            {
                var client = Helper.CreateClient();
                try
                {
                    var result = LnpChecker.Check(client, new[] { "1111" }, true).Result;
                } catch (BandwidthIrisException e)
                {
                    return;
                }
                catch (AggregateException e)
                {
                    Exception innerEx = e;
                    while (innerEx != null)
                    {
                        string mesg = innerEx.Message;
                        innerEx = innerEx.InnerException;
                        Console.WriteLine(mesg);
                    }
                    return;
                }
                catch (Exception e)
                {
                    return;
                }
                Assert.Fail("The exception was not thrown");
            }
        }
예제 #3
0
        public void CheckTest()
        {
            var request = new NumberPortabilityRequest
            {
                TnList = new[] { "1111", "2222", "3333" }
            };
            var response = new NumberPortabilityResponse
            {
                SupportedRateCenters = new[]
                {
                    new RateCenterGroup
                    {
                        RateCenter = "Center1",
                        City       = "City1",
                        State      = "State1",
                        Lata       = "11",
                        Tiers      = new [] { "111", "222", "333" },
                        TnList     = new [] { "1111", "2222", "3333" }
                    },
                },
                UnsupportedRateCenters = new RateCenterGroup[0]
            };

            using (var server = new HttpServer(new RequestHandler
            {
                EstimatedMethod = "POST",
                EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/lnpchecker?fullCheck=true", Helper.AccountId),
                EstimatedContent = Helper.ToXmlString(request),
                ContentToSend = Helper.CreateXmlContent(response)
            }))
            {
                var client = Helper.CreateClient();
                var result = LnpChecker.Check(client, new[] { "1111", "2222", "3333" }, true).Result;
                if (server.Error != null)
                {
                    throw server.Error;
                }
                Helper.AssertObjects(response, result);
            }
        }