MessageParser() 공개 메소드

public MessageParser ( string rawline ) : IrcMessageData
rawline string
리턴 IrcMessageData
예제 #1
0
        public void MessageParser()
        {
            var client = new IrcClient();

            var rawline = ":irc.example.com 001 meebey3 :Welcome to the EFnet Internet Relay Chat Network meebey3";
            var msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("irc.example.com", msg.From);
            Assert.AreEqual(null, msg.Nick);
            Assert.AreEqual(null, msg.Ident);
            Assert.AreEqual(null, msg.Host);
            Assert.AreEqual(ReplyCode.Welcome, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Login, msg.Type);
            Assert.AreEqual("Welcome to the EFnet Internet Relay Chat Network meebey3", msg.Message);
            Assert.AreEqual(null, msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);

            rawline = ":irc.example.com 002 meebey3 :Your host is irc.example.com[127.0.0.1/6667], running version hybrid-7.2.2+oftc1.6.9";
            msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("irc.example.com", msg.From);
            Assert.AreEqual(null, msg.Nick);
            Assert.AreEqual(null, msg.Ident);
            Assert.AreEqual(null, msg.Host);
            Assert.AreEqual(ReplyCode.YourHost, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Login, msg.Type);
            Assert.AreEqual("Your host is irc.example.com[127.0.0.1/6667], running version hybrid-7.2.2+oftc1.6.9", msg.Message);
            Assert.AreEqual(null, msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);

            rawline = ":irc.example.com 003 meebey3 :This server was created Aug  7 2011 at 12:43:41";
            msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("irc.example.com", msg.From);
            Assert.AreEqual(null, msg.Nick);
            Assert.AreEqual(null, msg.Ident);
            Assert.AreEqual(null, msg.Host);
            Assert.AreEqual(ReplyCode.Created, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Login, msg.Type);
            Assert.AreEqual("This server was created Aug  7 2011 at 12:43:41", msg.Message);
            Assert.AreEqual(null, msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);

            rawline = ":irc.example.com 004 meebey3 irc.example.com hybrid-7.2.2+oftc1.6.9 CDGPRSabcdfgiklnorsuwxyz biklmnopstveI bkloveI";
            msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("irc.example.com", msg.From);
            Assert.AreEqual(null, msg.Nick);
            Assert.AreEqual(null, msg.Ident);
            Assert.AreEqual(null, msg.Host);
            Assert.AreEqual(ReplyCode.MyInfo, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Login, msg.Type);
            Assert.AreEqual(null, msg.Message);
            Assert.AreEqual(null, msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);

            rawline = ":irc.example.com 005 meebey3 CALLERID CASEMAPPING=rfc1459 DEAF=D KICKLEN=160 MODES=4 NICKLEN=30 PREFIX=(ov)@+ STATUSMSG=@+ TOPICLEN=390 NETWORK=EFnet MAXLIST=beI:25 MAXTARGETS=4 CHANTYPES=#& :are supported by this server";
            msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("irc.example.com", msg.From);
            Assert.AreEqual(null, msg.Nick);
            Assert.AreEqual(null, msg.Ident);
            Assert.AreEqual(null, msg.Host);
            Assert.AreEqual(ReplyCode.Bounce, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Login, msg.Type);
            Assert.AreEqual("are supported by this server", msg.Message);
            Assert.AreEqual(null, msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);

            rawline = ":irc.example.com 005 meebey3 CHANLIMIT=#&:25 CHANNELLEN=50 CHANMODES=eIb,k,l,imnpstMRS KNOCK ELIST=CMNTU SAFELIST AWAYLEN=160 EXCEPTS=e INVEX=I :are supported by this server";
            msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("irc.example.com", msg.From);
            Assert.AreEqual(null, msg.Nick);
            Assert.AreEqual(null, msg.Ident);
            Assert.AreEqual(null, msg.Host);
            Assert.AreEqual(ReplyCode.Bounce, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Login, msg.Type);
            Assert.AreEqual("are supported by this server", msg.Message);
            Assert.AreEqual(null, msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);

            rawline = ":[email protected] JOIN :#debian.de";
            msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("[email protected]", msg.From);
            Assert.AreEqual("i_ron", msg.Nick);
            Assert.AreEqual("~zbuddy", msg.Ident);
            Assert.AreEqual("37.187.47.25", msg.Host);
            Assert.AreEqual(ReplyCode.Null, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Join, msg.Type);
            Assert.AreEqual("#debian.de", msg.Message);
            Assert.AreEqual("#debian.de", msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);
        }