Exemplo n.º 1
0
 Task ProcessClientAsync(TdsContext tdsContext, CancellationTokenSource cancelTokenSource)
 {
     try
     {
         var client = tdsContext.Client;
         while (!client.IsDead)
         {
             var command = client.GetGenericQuery();
             tdsContext.Request = TdsRequest.Parse(command);
             using (tdsContext.Response = new TdsResponse(client))
                 _handler(tdsContext);
             client.FlushPacket();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine($"Exception: {e.Message}");
         if (e.InnerException != null)
         {
             Console.WriteLine($"Inner exception: {e.InnerException.Message}");
         }
         Console.WriteLine("Connection closed.");
     }
     return(Task.CompletedTask);
 }
Exemplo n.º 2
0
        public void Should_parse_request()
        {
            // given
            var rawQuery = "Query";

            // when
            var tdsRequest = TdsRequest.Parse(rawQuery);

            // then
            Check.That(tdsRequest).IsNotNull();
            Check.That(tdsRequest.Query).IsEqualTo("Query");
        }