当前位置: 首页>>代码示例>>C#>>正文


C# Client.SendSms方法代码示例

本文整理汇总了C#中Client.SendSms方法的典型用法代码示例。如果您正苦于以下问题:C# Client.SendSms方法的具体用法?C# Client.SendSms怎么用?C# Client.SendSms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client的用法示例。


在下文中一共展示了Client.SendSms方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShouldNotBeAbleToPutCommaInNumbersTest

        public void ShouldNotBeAbleToPutCommaInNumbersTest()
        {
            var client = new Client("apikey", server.Url);

            Assert.Throws<InvalidOperationException>(() => client.SendSms(originator: "orig", body: "bODY", numbers: new string[]{"447796,354848"}));
        }
开发者ID:zensend,项目名称:zensend_csharp_api,代码行数:6,代码来源:ClientTest.cs

示例2: HandleAnErrorTest

        public void HandleAnErrorTest()
        {
            server.SetResponse("application/json", 400, @"{
              ""failure"": {
              ""failcode"": ""GENERIC_ERROR""
              }
            }");

            var client = new Client("apikey", server.Url);

            var e = Assert.Throws<ZenSendException>(() => client.SendSms(originator: "orig", body: "bODY", numbers: new string[]{"447796354848", "447796354847"}));

            Assert.Equal(HttpStatusCode.BadRequest, e.HttpStatus);
            Assert.Equal("GENERIC_ERROR", e.FailCode);
            Assert.Equal(null, e.Parameter);
        }
开发者ID:zensend,项目名称:zensend_csharp_api,代码行数:16,代码来源:ClientTest.cs

示例3: SendSmsWithOptionalParametersTest

        public void SendSmsWithOptionalParametersTest()
        {
            server.SetResponse("application/json", 200, @"
            {""success"":{""txguid"":""f8223367-64a8-4f97-856d-56d57432eaf9"",""numbers"":2,""smsparts"":1,""encoding"":""gsm"",""cost_in_pence"":123.4, ""new_balance_in_pence"":10.2}}");

            var client = new Client("apikey", server.Url);
            var result = client.SendSms(originator: "orig", body: "bODY", numbers: new string[]{"447796354848", "447796354847"}, originatorType: OriginatorType.Alphanumeric, timeToLiveInMinutes: 60, encoding: SmsEncoding.GSM);

            Assert.Equal(2, result.Numbers);
            Assert.Equal(1, result.SmsParts);
            Assert.Equal(123.4m, result.CostInPence);
            Assert.Equal(10.2m, result.NewBalanceInPence);
            Assert.Equal("gsm", result.Encoding);
            Assert.Equal("apikey", server.LastRequest.Headers["X-API-KEY"]);
            Assert.Equal("application/x-www-form-urlencoded", server.LastRequest.Headers["content-type"]);
            Assert.Equal("BODY=bODY&ORIGINATOR=orig&ORIGINATOR_TYPE=alpha&NUMBERS=447796354848%2c447796354847&TIMETOLIVE=60&ENCODING=gsm", server.LastBodyAsString);
        }
开发者ID:zensend,项目名称:zensend_csharp_api,代码行数:17,代码来源:ClientTest.cs

示例4: SendSmsTest

        public void SendSmsTest()
        {
            server.SetResponse("application/json", 200, @"
            {""success"":{""txguid"":""f8223367-64a8-4f97-856d-56d57432eaf9"",""numbers"":2,""smsparts"":1,""encoding"":""gsm"",""cost_in_pence"":12.34, ""new_balance_in_pence"":10.2}}");

            var client = new Client("apikey", server.Url);
            var result = client.SendSms(originator: "orig", body: "bODY", numbers: new string[]{"447796354848", "447796354847"});

            Assert.Equal(2, result.Numbers);
            Assert.Equal(1, result.SmsParts);
            Assert.Equal(12.34m, result.CostInPence);
            Assert.Equal(10.2m, result.NewBalanceInPence);
            Assert.Equal("gsm", result.Encoding);
            Assert.Equal("apikey", server.LastRequest.Headers["X-API-KEY"]);
            Assert.Equal("application/x-www-form-urlencoded", server.LastRequest.Headers["content-type"]);
            Assert.Equal("BODY=bODY&ORIGINATOR=orig&NUMBERS=447796354848%2c447796354847", server.LastBodyAsString);
        }
开发者ID:zensend,项目名称:zensend_csharp_api,代码行数:17,代码来源:ClientTest.cs

示例5: HandleNonJsonResponseTest

        public void HandleNonJsonResponseTest()
        {
            server.SetResponse("text/plain", 503, "Gateway Timeout");

            var client = new Client("apikey", server.Url);

            var e = Assert.Throws<ZenSendException>(() => client.SendSms(originator: "orig", body: "bODY", numbers: new string[]{"447796354848", "447796354847"}));

            Assert.Equal(HttpStatusCode.ServiceUnavailable, e.HttpStatus);
            Assert.Equal(null, e.FailCode);
            Assert.Equal(null, e.Parameter);
        }
开发者ID:zensend,项目名称:zensend_csharp_api,代码行数:12,代码来源:ClientTest.cs

示例6: Invalid_auth_values_throws

 public void Invalid_auth_values_throws()
 {
     var client = new Client("12345", "ABCDE");
     client.SendSms(PhoneNumberVirtual, PhoneNumberReal, "Test helloo plivoooo");
 }
开发者ID:jnus,项目名称:nPlivo,代码行数:5,代码来源:Tests.cs

示例7: CanSent

 public void CanSent()
 {
     var client = new Client(AuthId, AuthToken);
     client.SendSms(PhoneNumberVirtual, PhoneNumberReal, "Test helloo plivoooo");
 }
开发者ID:jnus,项目名称:nPlivo,代码行数:5,代码来源:Tests.cs


注:本文中的Client.SendSms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。