* Small bug fixes which caused exception on small text sending
[circ.git] / Tests / DefaultParserTest.cs
blob295030e007f636debf6477765dc2a1ea2225a682
1 using Circ.Lib;
2 using Circ.Backend;
3 using NUnit.Core;
4 using NUnit.Framework;
6 [TestFixtureAttribute]
7 public partial class DefaultParserTest
10 public DefaultParserTest()
14 IParser parser;
16 [SetUp]
17 public void Setup()
19 parser = new DefaultParser();
22 [Test]
23 public void TestPingPong()
25 string ping = "PING :B4C785BC";
26 Assert.IsTrue(parser.RetrieveMessageType(ping) == MessageType.Action, "#1");
27 Assert.IsTrue(parser.RetrieveAction(ping) == ActionType.Ping, "#2");
28 Assert.IsTrue(parser.RetrieveParameters(ping) == ":B4C785BC", "#3");
29 Assert.IsTrue(Rfc.Pong(parser.RetrieveParameters(ping)) == "PONG :B4C785BC"+Rfc.Crlf, "#4");
32 [Test]
33 public void BadIndentification()
35 string badIdent = ":trucnuche.epikne.org 451 :You have not registered";
36 string other = ":trucnuche.epikne.org 453 :Some other error";
38 Assert.IsTrue(((parser.RetrieveMessageType(badIdent) == MessageType.Reply &&
39 parser.RetrieveNumericalReply(badIdent) == 451)), "#1");
40 Assert.IsFalse(((parser.RetrieveMessageType(other) == MessageType.Reply &&
41 parser.RetrieveNumericalReply(other) == 451)), "#2");
44 [Test]
45 public void TestNoticeAuth()
47 string auth = ":la-defense2.fr.epiknet.org NOTICE AUTH :*** Found your hostname";
48 string nonAuth = ":Themis!services@olympe.epiknet.org NOTICE Garuma :Si vous ne changez pas d'ici 1 minute, je changerai votre pseudo.";
50 Assert.IsTrue(parser.RetrieveMessageType(auth) == MessageType.Notice, "#1");
51 Assert.IsTrue(parser.RetrieveParameters(auth).Substring(0, 4).ToUpperInvariant() == "AUTH", "#2");
53 Assert.IsTrue(parser.RetrieveMessageType(nonAuth) == MessageType.Notice, "#3");
54 Assert.IsTrue(parser.RetrieveParameters(nonAuth).Substring(0, 4).ToUpperInvariant() != "AUTH", "#4");
57 [Test]
58 public void TestUserList()
60 string userList = ":la-defense2.fr.epiknet.org 353 Garuma = #sdz-unix :Garuma @Terpsichore GarulfoLinux";
62 Assert.IsTrue(parser.RetrieveMessageType(userList) == MessageType.Reply, "#1");
63 Assert.IsTrue(parser.RetrieveNumericalReply(userList) == Rfc.NamesReply, "#2");
64 Assert.IsTrue(string.Join(" ", parser.RetrieveUsersList(userList)) == "Garuma @Terpsichore GarulfoLinux", "#3");
67 [Test]
68 public void TestPrivateMessageChannel()
70 string cmd = ":Garuma_!~garuma@EpiK-B8FEBE74.fbx.proxad.net PRIVMSG #sdz-unix :Anonyme942099: haha couillon a deux balle";
71 Assert.IsTrue(parser.RetrieveMessageType(cmd) == MessageType.PrivateMessage, "#1");
72 Assert.IsTrue(parser.RetrieveMessageTarget(cmd) == "#sdz-unix", "#2");
73 Assert.IsTrue(parser.RetrieveMessage(cmd) == "Anonyme942099: haha couillon a deux balle", "#3 : Message is "+parser.RetrieveMessage(cmd));
76 [NUnit.Framework.TestAttribute()]
77 [NUnit.Framework.IgnoreAttribute()]
78 void RetrieveAuthorTest()
80 // TODO: Implement unit test for RetrieveAuthorTest
83 [NUnit.Framework.TestAttribute()]
84 [NUnit.Framework.IgnoreAttribute()]
85 void RetrieveMessageTest()
87 // TODO: Implement unit test for RetrieveMessageTest
90 [NUnit.Framework.TestAttribute()]
91 [NUnit.Framework.IgnoreAttribute()]
92 void RetrieveMessageTargetTest()
94 // TODO: Implement unit test for RetrieveMessageTargetTest
97 [NUnit.Framework.TestAttribute()]
98 [NUnit.Framework.IgnoreAttribute()]
99 void RetrieveMessageTypeTest()
101 // TODO: Implement unit test for RetrieveMessageTypeTest
104 [NUnit.Framework.TestAttribute()]
105 [NUnit.Framework.IgnoreAttribute()]
106 void RetrieveActionTest()
108 // TODO: Implement unit test for RetrieveActionTest
111 [NUnit.Framework.TestAttribute()]
112 [NUnit.Framework.IgnoreAttribute()]
113 void RetrieveParametersTest()
115 // TODO: Implement unit test for RetrieveParametersTest
118 [NUnit.Framework.TestAttribute()]
119 [NUnit.Framework.IgnoreAttribute()]
120 void RetrieveNoticeTextTest()
122 // TODO: Implement unit test for RetrieveNoticeTextTest
125 [NUnit.Framework.TestAttribute()]
126 [NUnit.Framework.IgnoreAttribute()]
127 void RetrieveNumericalReplyTest()
129 // TODO: Implement unit test for RetrieveNumericalReplyTest
132 [NUnit.Framework.TestAttribute()]
133 [NUnit.Framework.IgnoreAttribute()]
134 void RetrieveUsersListTest()
136 // TODO: Implement unit test for RetrieveUsersListTest
139 [NUnit.Framework.TestAttribute()]
140 [NUnit.Framework.IgnoreAttribute()]
141 void RetrieveTopicTest()
143 // TODO: Implement unit test for RetrieveTopicTest
146 [NUnit.Framework.TestAttribute()]
147 [NUnit.Framework.IgnoreAttribute()]
148 void RetrieveChannelTargetTest()
150 // TODO: Implement unit test for RetrieveChannelTargetTest
153 [NUnit.Framework.TestAttribute()]
154 [NUnit.Framework.IgnoreAttribute()]
155 void StripFirstColonTest()
157 // TODO: Implement unit test for StripFirstColonTest
160 [NUnit.Framework.TestAttribute()]
161 [NUnit.Framework.IgnoreAttribute()]
162 void EqualsTest()
164 // TODO: Implement unit test for EqualsTest
167 [NUnit.Framework.TestAttribute()]
168 [NUnit.Framework.IgnoreAttribute()]
169 void GetHashCodeTest()
171 // TODO: Implement unit test for GetHashCodeTest
174 [NUnit.Framework.TestAttribute()]
175 [NUnit.Framework.IgnoreAttribute()]
176 void GetTypeTest()
178 // TODO: Implement unit test for GetTypeTest
181 [NUnit.Framework.TestAttribute()]
182 [NUnit.Framework.IgnoreAttribute()]
183 void ToStringTest()
185 // TODO: Implement unit test for ToStringTest