8 public partial class DefaultParserTest
11 public DefaultParserTest()
20 parser
= new DefaultParser();
24 public void TestPingPong()
26 string ping
= "PING :B4C785BC";
27 Assert
.IsTrue(parser
.RetrieveMessageType(ping
) == MessageType
.Action
, "#1");
28 Assert
.IsTrue(parser
.RetrieveAction(ping
) == ActionType
.Ping
, "#2");
29 Assert
.IsTrue(parser
.RetrieveParameters(ping
) == ":B4C785BC", "#3");
30 Assert
.IsTrue(Rfc
.Pong(parser
.RetrieveParameters(ping
)) == "PONG :B4C785BC"+Rfc
.Crlf
, "#4");
34 public void BadIndentification()
36 string badIdent
= ":trucnuche.epikne.org 451 :You have not registered";
37 string other
= ":trucnuche.epikne.org 453 :Some other error";
39 Assert
.IsTrue(((parser
.RetrieveMessageType(badIdent
) == MessageType
.Reply
&&
40 parser
.RetrieveNumericalReply(badIdent
) == 451)), "#1");
41 Assert
.IsFalse(((parser
.RetrieveMessageType(other
) == MessageType
.Reply
&&
42 parser
.RetrieveNumericalReply(other
) == 451)), "#2");
46 public void TestNoticeAuth()
48 string auth
= ":la-defense2.fr.epiknet.org NOTICE AUTH :*** Found your hostname";
49 string nonAuth
= ":Themis!services@olympe.epiknet.org NOTICE Garuma :Si vous ne changez pas d'ici 1 minute, je changerai votre pseudo.";
51 Assert
.IsTrue(parser
.RetrieveMessageType(auth
) == MessageType
.Notice
, "#1");
52 Assert
.IsTrue(parser
.RetrieveParameters(auth
).Substring(0, 4).ToUpperInvariant() == "AUTH", "#2");
54 Assert
.IsTrue(parser
.RetrieveMessageType(nonAuth
) == MessageType
.Notice
, "#3");
55 Assert
.IsTrue(parser
.RetrieveParameters(nonAuth
).Substring(0, 4).ToUpperInvariant() != "AUTH", "#4");
59 public void TestUserList()
61 string userList
= ":la-defense2.fr.epiknet.org 353 Garuma = #sdz-unix :Garuma @Terpsichore GarulfoLinux";
63 Assert
.IsTrue(parser
.RetrieveMessageType(userList
) == MessageType
.Reply
, "#1");
64 Assert
.IsTrue(parser
.RetrieveNumericalReply(userList
) == Rfc
.NamesReply
, "#2");
65 Assert
.IsTrue(string.Join(" ", parser
.RetrieveUsersList(userList
)) == "Garuma @Terpsichore GarulfoLinux", "#3");
69 public void TestPrivateMessageChannel()
71 string cmd
= ":Garuma_!~garuma@EpiK-B8FEBE74.fbx.proxad.net PRIVMSG #sdz-unix :Anonyme942099: haha couillon a deux balle";
72 Assert
.IsTrue(parser
.RetrieveMessageType(cmd
) == MessageType
.PrivateMessage
, "#1");
73 Assert
.IsTrue(parser
.RetrieveMessageTarget(cmd
) == "#sdz-unix", "#2");
74 Assert
.IsTrue(parser
.RetrieveMessage(cmd
) == "Anonyme942099: haha couillon a deux balle", "#3 : Message is "+parser
.RetrieveMessage(cmd
));
78 public void RetrieveJoinInformationsTest()
80 string join = ":Garuma_!~garuma@EpiK-B8FEBE74.fbx.proxad.net JOIN :#sdz-unix";
82 Assert
.IsTrue(parser
.RetrieveMessageType(join) == MessageType
.Action
, "MessageType");
83 Assert
.IsTrue(parser
.RetrieveAction(join) == ActionType
.Join
, "ActionType");
84 Assert
.IsTrue(parser
.RetrieveChannelTarget(join) == "#sdz-unix", "ChannelTarget");
86 string[] temp
= parser
.RetrieveJoinInformations(join);
87 Assert
.IsNotNull(temp
, "NotNullInformations");
88 Assert
.IsNotEmpty(temp
);
89 Assert
.IsTrue(temp
[0].Equals("Garuma_", System
.StringComparison
.Ordinal
), "NickEquality : " + temp
[0]);
90 Assert
.IsTrue(temp
[1].Equals("~garuma", System
.StringComparison
.Ordinal
), "UsernameEquality : " + temp
[1]);
94 public void RetrieveQuitInformationsTest()
96 string cmd
= ":Garuma!~garuma@EpiK-B8FEBE74.fbx.proxad.net QUIT :Client exited";
98 Assert
.IsTrue(parser
.RetrieveMessageType(cmd
) == MessageType
.Action
, "MessageType");
99 Assert
.IsTrue(parser
.RetrieveAction(cmd
) == ActionType
.Quit
, "ActionType");
101 string[] temp
= parser
.RetrieveQuitInformations(cmd
);
102 Assert
.IsNotNull(temp
, "NotNullInformations");
103 Assert
.IsNotEmpty(temp
);
104 Assert
.IsTrue(temp
[0].Equals("Garuma", System
.StringComparison
.Ordinal
), "NickEquality : " + temp
[0]);
105 Assert
.IsTrue(temp
[1].Equals("Client exited", System
.StringComparison
.Ordinal
), "QuitMessageEquality : " + temp
[1]);
109 public void RetrievePartInformationsTest()
111 string cmd
= ":Garuma!~garuma@EpiK-B8FEBE74.fbx.proxad.net PART #sdz-unix :Client exited";
113 Assert
.IsTrue(parser
.RetrieveMessageType(cmd
) == MessageType
.Action
, "MessageType");
114 Assert
.IsTrue(parser
.RetrieveAction(cmd
) == ActionType
.Part
, "ActionType");
115 Assert
.IsTrue(parser
.RetrieveChannelTarget(cmd
) == "#sdz-unix", "ChannelTarget : " + parser
.RetrieveChannelTarget(cmd
));
117 string[] temp
= parser
.RetrieveQuitInformations(cmd
);
118 Assert
.IsNotNull(temp
, "NotNullInformations");
119 Assert
.IsNotEmpty(temp
);
120 Assert
.IsTrue(temp
[0].Equals("Garuma", System
.StringComparison
.Ordinal
), "NickEquality : " + temp
[0]);
121 Assert
.IsTrue(temp
[1].Equals("Client exited", System
.StringComparison
.Ordinal
), "QuitMessageEquality : " + temp
[1]);
124 [NUnit
.Framework
.TestAttribute()]
125 [NUnit
.Framework
.IgnoreAttribute()]
126 void RetrieveAuthorTest()
128 // TODO: Implement unit test for RetrieveAuthorTest
131 [NUnit
.Framework
.TestAttribute()]
132 [NUnit
.Framework
.IgnoreAttribute()]
133 void RetrieveMessageTest()
135 // TODO: Implement unit test for RetrieveMessageTest
138 [NUnit
.Framework
.TestAttribute()]
139 [NUnit
.Framework
.IgnoreAttribute()]
140 void RetrieveMessageTargetTest()
142 // TODO: Implement unit test for RetrieveMessageTargetTest
145 [NUnit
.Framework
.TestAttribute()]
146 [NUnit
.Framework
.IgnoreAttribute()]
147 void RetrieveMessageTypeTest()
149 // TODO: Implement unit test for RetrieveMessageTypeTest
152 [NUnit
.Framework
.TestAttribute()]
153 [NUnit
.Framework
.IgnoreAttribute()]
154 void RetrieveActionTest()
156 // TODO: Implement unit test for RetrieveActionTest
159 [NUnit
.Framework
.TestAttribute()]
160 [NUnit
.Framework
.IgnoreAttribute()]
161 void RetrieveParametersTest()
163 // TODO: Implement unit test for RetrieveParametersTest
166 [NUnit
.Framework
.TestAttribute()]
167 [NUnit
.Framework
.IgnoreAttribute()]
168 void RetrieveNoticeTextTest()
170 // TODO: Implement unit test for RetrieveNoticeTextTest
173 [NUnit
.Framework
.TestAttribute()]
174 [NUnit
.Framework
.IgnoreAttribute()]
175 void RetrieveNumericalReplyTest()
177 // TODO: Implement unit test for RetrieveNumericalReplyTest
180 [NUnit
.Framework
.TestAttribute()]
181 [NUnit
.Framework
.IgnoreAttribute()]
182 void RetrieveUsersListTest()
184 // TODO: Implement unit test for RetrieveUsersListTest
187 [NUnit
.Framework
.TestAttribute()]
188 [NUnit
.Framework
.IgnoreAttribute()]
189 void RetrieveTopicTest()
191 // TODO: Implement unit test for RetrieveTopicTest
194 [NUnit
.Framework
.TestAttribute()]
195 public void RetrieveChannelTargetTest()
197 string cmd
= ":la-defense2.fr.epiknet.org 332 Garuma #sdz-unix :Canal IRC Francophone dédié à l'utilisation/au parlage de systèmes Unix --- Salut à toi, et mort aux cons : http://chl.be/vista/";
198 string cmd2
= ":la-defense2.fr.epiknet.org 353 Garuma = #sdz-unix :Garuma @Terpsichore GarulfoLinux ";
199 string cmd3
= ":Garuma_!~garuma@EpiK-B8FEBE74.fbx.proxad.net JOIN :#sdz-unix";
201 string result
= null;
203 Assert
.IsNotNull((result
= parser
.RetrieveChannelTarget(cmd
)));
204 Assert
.IsTrue(result
.Equals("#sdz-unix", StringComparison
.Ordinal
), "Equality : " + result
);
206 Assert
.IsNotNull((result
= parser
.RetrieveChannelTarget(cmd2
)));
207 Assert
.IsTrue(result
.Equals("#sdz-unix", StringComparison
.Ordinal
), "Equality 2 : " + result
);
209 Assert
.IsNotNull((result
= parser
.RetrieveChannelTarget(cmd3
)));
210 Assert
.IsTrue(result
.Equals("#sdz-unix", StringComparison
.Ordinal
), "Equality 3 : " + result
);
213 [NUnit
.Framework
.TestAttribute()]
214 [NUnit
.Framework
.IgnoreAttribute()]
215 void StripFirstColonTest()
217 // TODO: Implement unit test for StripFirstColonTest
220 [NUnit
.Framework
.TestAttribute()]
221 [NUnit
.Framework
.IgnoreAttribute()]
224 // TODO: Implement unit test for EqualsTest
227 [NUnit
.Framework
.TestAttribute()]
228 [NUnit
.Framework
.IgnoreAttribute()]
229 void GetHashCodeTest()
231 // TODO: Implement unit test for GetHashCodeTest
234 [NUnit
.Framework
.TestAttribute()]
235 [NUnit
.Framework
.IgnoreAttribute()]
238 // TODO: Implement unit test for GetTypeTest
241 [NUnit
.Framework
.TestAttribute()]
242 [NUnit
.Framework
.IgnoreAttribute()]
245 // TODO: Implement unit test for ToStringTest