public void TestSetup() { this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircWriter = new Mock <IIrcWriter>(MockBehavior.Strict); this.responseReceived = null; JoinHandlerConfig joinHandlerConfig = new JoinHandlerConfig { JoinAction = this.JoinFunction }; this.uut = new JoinHandler(joinHandlerConfig); }
private void OnJoinChannel(JoinHandlerArgs args) { if (args.User.Equals(this.ircConfig.Nick, StringComparison.InvariantCultureIgnoreCase)) { string channel = args.Channel; ChaskisEvent e = this.chaskisEventCreator.CreateTargetedEvent( "chaskis", new Dictionary <string, string>() { ["QUERY"] = "VERSION", ["PLUGIN"] = "chaskis" }, new Dictionary <string, string>() { ["CHANNEL"] = channel } ); this.eventSender.SendChaskisEvent(e); } }
// ---- Handlers ---- /// <summary> /// Ran when someone joins the channel. /// </summary> /// <param name="writer">The means to write to an IRC channel.</param> /// <param name="response">The command from the server.</param> private void JoinMessage(JoinHandlerArgs args) { args.Writer.SendMessage( args.User + " has joined " + args.Channel, args.Channel ); ChaskisEvent e = this.eventCreator.CreateTargetedEvent( "karmabot", new Dictionary <string, string>() { ["ACTION"] = "QUERY", ["NAME"] = args.User }, new Dictionary <string, string>() { ["CHANNEL"] = args.Channel, ["NAME"] = args.User } ); this.eventSender.SendChaskisEvent(e); }
public void ConstructorTest() { Mock <IIrcWriter> writer = new Mock <IIrcWriter>(MockBehavior.Strict); const string user = "******"; const string channel = "channel"; Regex regex = new Regex(".+"); System.Text.RegularExpressions.Match match = regex.Match("something"); JoinHandlerArgs uut = new JoinHandlerArgs( writer.Object, user, channel, regex, match ); Assert.AreSame(writer.Object, uut.Writer); Assert.AreEqual(user, uut.User); Assert.AreEqual(channel, uut.Channel); Assert.AreSame(regex, uut.Regex); Assert.AreSame(match, uut.Match); }
/// <summary> /// The function that is called /// </summary> private void JoinFunction(JoinHandlerArgs args) { Assert.AreSame(this.ircWriter.Object, args.Writer); this.responseReceived = args; }