本文整理汇总了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"}));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例6: Invalid_auth_values_throws
public void Invalid_auth_values_throws()
{
var client = new Client("12345", "ABCDE");
client.SendSms(PhoneNumberVirtual, PhoneNumberReal, "Test helloo plivoooo");
}
示例7: CanSent
public void CanSent()
{
var client = new Client(AuthId, AuthToken);
client.SendSms(PhoneNumberVirtual, PhoneNumberReal, "Test helloo plivoooo");
}