public void SendMessage_EmptyMessage_WontSend() { var socketmock = Substitute.For <ISocket>(); var client = new TextClient(socketmock); client.Sendmessage(string.Empty); socketmock.DidNotReceiveWithAnyArgs().Send(default, default, default);
public override async Task <SmtpResponse> SaveAsync(ISessionContext context, IMessageTransaction transaction, CancellationToken cancellationToken) { var statusUser = Config.GetSection("StatusUser").Value; var alarmUser = Config.GetSection("AlarmUser").Value; var textMessage = (ITextMessage)transaction.Message; var message = MimeMessage.Load(textMessage.Content); var user = transaction.To.First().User; // // Send SMS in alert event only // if (user.Equals(alarmUser, StringComparison.InvariantCultureIgnoreCase)) { Logger.LogInformation("Received alarm event"); var apiKey = Guid.Parse(Config.GetSection("ApiKey").Value); var from = Config.GetSection("From").Value; var recipients = Config.GetSection("Recipients").GetChildren().Select(e => e.Value).ToList(); Logger.LogInformation( $"Will send alarm SMS to the following recipients: {string.Join(", ", recipients)}"); var client = new TextClient(apiKey); var result = await client .SendMessageAsync(message.TextBody, from, recipients, transaction.From.User, cancellationToken) .ConfigureAwait(false); if (result.statusCode == TextClientStatusCode.Ok) { Logger.LogInformation($"Successfully sent the following message to recipients: {message.TextBody}"); return(await Task.FromResult(SmtpResponse.Ok)); } Logger.LogError($"Message delivery failed: {result.statusMessage} ({result.statusCode})"); return(await Task.FromResult(SmtpResponse.TransactionFailed)); } if (user.Equals(statusUser, StringComparison.InvariantCultureIgnoreCase)) { Logger.LogInformation($"Received status change: {message.TextBody}"); } else { Logger.LogWarning($"Unknown message received (maybe a test?): {message.TextBody}"); } return(await Task.FromResult(SmtpResponse.Ok)); }
public async Task SendSMS(Appointment appointment) { List <string> receivers = new List <string>(); receivers.Add(appointment.patient.PhoneNumber); var client = new TextClient(new Guid(config.GetSection("ApiKey").Value)); var result = await client.SendMessageAsync(string.Format("You have an appointment at {0} with doctor {1}. Description: {2}", appointment.DateTime, appointment.doctor.Name, appointment.Description), "CMProftaak", receivers, null).ConfigureAwait(false); }
static void Main(string[] args) { Console.Write("Enter server ip:"); var serverip = Console.ReadLine(); Console.Write("Enter port number:"); var port = Console.ReadLine(); Console.WriteLine("Select Ip address to send message"); var client = new TextClient(); try { client.StartClient(serverip, int.Parse(port)); } catch (Exception ex) { Console.WriteLine(ex.Message); } client.OnMessageReceived += Client_OnMessageReceived; string selectedClientip = Console.ReadLine(); Console.WriteLine("Conversation started with " + selectedClientip); while (true) { string message = Console.ReadLine(); if (selectedClientip == "All") { Console.WriteLine("Sending..."); } else { client.Sendmessage(selectedClientip + "_" + message); } } }
static void Main(string[] args) { #if NO_AUTH // not using SefariaClient #else var client = new SefariaClient(); Console.WriteLine(client.ToString()); #endif while (true) { Console.Write("> "); string input = Console.ReadLine(); if (input != null) { if (input.Equals("quit")) { break; } if (input.Equals("titles")) { #if NO_AUTH var index = IndexClient.GetTitles(); #else var index = client.Index.GetTitles(); #endif foreach (var title in index.Books) { Console.WriteLine(title); } continue; } if (input.Equals("contents")) { #if NO_AUTH var indices = IndexClient.GetContents(); #else var indices = client.Index.GetContents(); #endif //todo print out index Console.WriteLine(indices.ToString()); continue; } // todo output specific indices (e.g. genesis) } try { #if NO_AUTH var text = TextClient.GetText(input, false, false); var links = LinksClient.GetLinks(input); #else var text = client.Texts.GetText(input); var links = client.Links.GetLinks(input); #endif if (text.Error != null) { Console.WriteLine(text.Error); } else { // texts for (int i = 0; i < text.TextList.Count; i++) { Console.WriteLine(text.TextList[i]); Debug.WriteLine(text.HebrewTextList[i]); } // links foreach (var link in links) { Console.WriteLine(link.Ref); } } } catch (Exception e) { Console.WriteLine(e); } } }
public WebSocketTextTester(Uri uri) { Client = new TextClient(uri); }
static void Main(string[] args) { var ship = new BaubleShip(); TextClient <BasicGameInfo> .run("172.18.20.175", ship, 2012); }
public static void Main() { Console.WriteLine("=========== Swig Default Test ==========="); int result = NativeCode.Fact(10); Console.WriteLine("fact : " + result); int result1 = NativeCode.MyMod(2, 5); Console.WriteLine("my_mode : " + result1); Console.WriteLine("=========== Swig Array Test ==========="); int[] source = { 1, 2, 3 }; int[] target = new int[source.Length]; NativeCode.MyArrayCopy(source, target, target.Length); Console.WriteLine("Contents of copy target array using default marshaling"); PrintArray(target); target = new int[source.Length]; NativeCode.myArrayCopyUsingFixedArrays(source, target, target.Length); Console.WriteLine("Contents of copy target array using fixed arrays"); PrintArray(target); target = new int[] { 4, 5, 6 }; NativeCode.MyArraySwap(source, target, target.Length); Console.WriteLine("Contents of arrays after swapping using default marshaling"); PrintArray(source); PrintArray(target); source = new int[] { 1, 2, 3 }; target = new int[] { 4, 5, 6 }; NativeCode.myArraySwapUsingFixedArrays(source, target, target.Length); Console.WriteLine("Contents of arrays after swapping using fixed arrays"); PrintArray(source); PrintArray(target); Console.WriteLine("=========== Swig Struct Test ==========="); TestInfo info = new TestInfo(); info.BuildingName = "shinagawa"; info.OfficeName = "jr office"; info.PersionName = "joso"; TextClient textClient = new TextClient("http://google.com", "english", info, TestType.TESTTYPEOK); string urlStr = NativeCode.GetTestString(textClient); Console.WriteLine("url string : " + urlStr); string language = NativeCode.GetTestLang(textClient); Console.WriteLine("language : " + language); Console.WriteLine("=========== Swig function pointer ==========="); FuncPtCallback callback = new FuncPtCallback(CallbackTest); NativeCode.TestExec("Called C Function pointer??", callback); FuncPtCallback callback1 = new FuncPtCallback(CallbackTest1); NativeCode.TestExec("No Problem Callback", callback1); FuncPtIntCallback intCallback = new FuncPtIntCallback(IntCallbackTest); NativeCode.SetCallback(intCallback); Console.WriteLine("=========== Swig struct with function pointer ==========="); FuncPtrStructTest structPtrFuncTest = new FuncPtrStructTest(); structPtrFuncTest.Func1 = Func1CallbackTest; structPtrFuncTest.Func2 = Func2CallbackTest; structPtrFuncTest.Func3 = Func3CallbackTest; structPtrFuncTest.GetFuncData = GetFuncDataCallbackTest; NativeCode.RegistFuncPtrStruct(structPtrFuncTest); NativeCode.CallStructFunc1(); NativeCode.CallStructFunc2(); NativeCode.CallStructFunc3(); NativeCode.CallStructGetFuncData(); FuncPtrTest funcPtrTest = new FuncPtrTest(); funcPtrTest.SetFuncPtrStructTest = SetFuncPtrStructTestCallback; NativeCode.RegistAndCallFuncPtrs(funcPtrTest); Console.WriteLine("=========== Int Array Struct Test ==========="); IntArrayStructTest intArrayStructTest = new IntArrayStructTest(); intArrayStructTest.Test1 = new int[] { 3, 5, 7, 8, 9, 10, 14, 25, 30 }; intArrayStructTest.Test2 = new int[] { 10, 35, 67, 89, 100 }; Console.WriteLine("intArrayStructTest Test1 : {0}", string.Join(",", intArrayStructTest.Test1)); Console.WriteLine("intArrayStructTest Test2 : {0}", string.Join(",", intArrayStructTest.Test2)); Console.WriteLine("intArrayStructTest Test1[3] : {0}", intArrayStructTest.Test1[3]); Console.WriteLine("intArrayStructTest Test2[4] : {0}", intArrayStructTest.Test2[4]); string[] names = new string[] { "james", "micle", "jonson" }; NativeCode.StringArrayTest(names, names.Length); Console.WriteLine("=========== Swig Test End ==========="); }
public void StartClient_PortLessThen0_Throws() { var textclient = new TextClient(); textclient.StartClient("10.10.0.0", -23); }
public void StartClient_PortMoreThen_Throws() { var textclient = new TextClient(); textclient.StartClient("10.10.0.0", 655351); }
public void StartClient_PortSigned_Throws() { var textclient = new TextClient(); textclient.StartClient("10.10.0.0", -1); }
public void StartClient_ServerIpWrongFormat_Throws() { var textclient = new TextClient(); textclient.StartClient("wrongformat", 1); }
public void StartClient_ServerIpNullOrEmpty_Throws() { var textclient = new TextClient(); textclient.StartClient(null, 1); }
public void Ctor_ArgumentNull_Throws() { var textclient = new TextClient(null); }