public void SendWitsSentence()
        {
            var          baseSent       = WitsHelpers.CreateDefaultWitsSentence();
            WitsSentence sentenceResult = null;

            using (var host = new WitsHost(6666, WitsLevel.Level0,
                                           new WitsPostProcessorSimple[]
            {
                new WitsPostProcessorSimple((sentences) =>
                {
                    sentenceResult = sentences.First();
                })
            }))
            {
                host.Start();

                using (var client = new WitsClient("127.0.0.1", 6666))
                {
                    client.Connect();
                    client.SendWitsSentence(baseSent);
                    Thread.Sleep(2000);
                }
            }

            Assert.AreEqual(baseSent.ToString(), sentenceResult.ToString());
        }
示例#2
0
        public void DeserializeWitsSentenceMethod()
        {
            var sentBase = wh.CreateDefaultWitsSentence();
            var sent     = WitsSentence.Parse(wh.WitsString);

            Assert.AreEqual(sentBase.Records, sent.Records);
        }
示例#3
0
 /// <summary>
 /// Send WITS message
 /// </summary>
 /// <param name="sentence">WITS sentence <see cref="WitsSentence"/></param>
 public void SendWitsSentence(WitsSentence sentence)
 {
     SendWitsSentenceCollection(new List <WitsSentence>()
     {
         sentence
     });
 }
示例#4
0
        public static WitsSentence CreateDefaultWitsSentence()
        {
            var sent = new WitsSentence();

            sent.Records.Add(WitsRecord.Parse("01021000"));
            sent.Records.Add(WitsRecord.Parse("01031000"));
            return(sent);
        }
示例#5
0
 /// <summary>
 /// Send Wits sentence
 /// </summary>
 /// <param name="sentence">Wits sentence</param>
 public void SendWitsSentence(WitsSentence sentence)
 {
     try
     {
         _witsStrategy.SendWitsSentence(sentence);
     }
     catch (Exception ex)
     {
         _logger.Log(LogLevel.Error, ex, "Ошибка ассинхронного подключения");
     }
 }