Ejemplo n.º 1
0
 public void GNTPParserTest()
 {
     var pw = new PasswordManager();
     var info = new RequestInfo();
     var parser = new GNTPParser(pw, false, true, true, true, info);
     var items = new List<IGNTPRequest>();
     parser.MessageParsed += (req) =>
     {
         items.Add(req);
     };
     parser.Error += (error) =>
     {
         Assert.Fail("ErrorCode={0}, Description={1}", error.ErrorCode, error.ErrorDescription);
     };
     ParseAll(parser);
     Assert.IsTrue(items.Count > 0);
     foreach (var item in items) {
         if (item.Directive == RequestType.NOTIFY) {
             var nLog = NeithNotificationRec.FromHeaders(item.Headers);
         }
         if (item.Directive == RequestType.REGISTER) {
             var app = Application.FromHeaders(item.Headers);
             Assert.AreEqual("SurfWriter", app.Name);
         }
     }
 }
Ejemplo n.º 2
0
 private static void ParseAll(GNTPParser parser)
 {
     var remain = TestBytes.Length;
     var index = 0;
     var length = 0;
     while (true) {
         var data = GetBytes(index, length);
         var s = Encoding.UTF8.GetString(data);
         var next = parser.Parse(data);
         if (!next.ShouldContinue) break;
         index += length;
         length = GetLength(next, index);
     }
 }