public void TestSetup() { this.ircConfig = TestHelpers.GetTestIrcConfig(); ircConnection = new MockIrcConnection(this.ircConfig); responseReceived = null; this.uut = new PartHandler(PartFunction); }
public void ConnectWithNickServAndServerPasswordTest() { IrcConfig ircConfig = new IrcConfig { Nick = nick, NickServPassword = nickServPass, QuitMessage = quitMessage, RealName = realName, ServerPassword = serverPassword, UserName = userName, RateLimit = 0 }; ircConfig.Channels.Add(channel1); ircConfig.Channels.Add(channel2); using (IrcConnection connection = new IrcConnection(ircConfig, this.parsingQueue.Object, this.mac.Object)) { // We need to send the passwords too! this.mac.Setup( m => m.WriteLine("PRIVMSG NickServ :IDENTIFY {0}", nickServPass) ); this.mac.Setup( m => m.WriteLine("PASS {0}", serverPassword) ); this.DoConnect(connection); this.DoDisconnect(connection); } this.mac.VerifyAll(); }
public void TestSetup() { this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircWriter = new Mock <IIrcWriter>(MockBehavior.Strict); this.uut = new PongHandler(); }
public override void Entry(IModHelper helper) { //Lets load up the config file. _config = helper.ReadConfig <IrcConfig>(); //Set up Events helper.Events.GameLoop.GameLaunched += GameLaunched; helper.Events.Input.ButtonPressed += ButtonPressed; }
/// <summary> /// Instantiates a new IRC server connector /// </summary> /// <param name="config">The configuration for the IRC server connection and any controller attached</param> public IrcConnector(IrcConfig config) { config.IsValid(true); Config = config; if (config.ConnectOnInstantiation) { Connect(); } }
/// <summary> /// Ensures the given IRCConfig is not valid. /// </summary> /// <param name="config">The config to check.</param> private void CheckNotValid( IrcConfig config ) { Assert.Throws<ValidationException>( () => config.Validate() ); ReadOnlyIrcConfig roConfig = new ReadOnlyIrcConfig( config.Clone() ); Assert.Throws<ValidationException>( () => roConfig.Validate() ); IIrcConfig iircConfig = config; Assert.Throws<ValidationException>( () => iircConfig.Validate() ); }
public void OneTimeSetUp() { this.ircConfig = TestHelpers.GetTestIrcConfig(); this.factoryInstance = TestHelpers.CreateEventFactory(); //this.sourcePluginName = "USERLISTBOT"; string creatorPluginName = TestHelpers.FactoryPluginNames[1]; this.creator = this.factoryInstance.EventCreators[creatorPluginName]; this.creatorPluginName = creatorPluginName.ToUpper(); }
public InstagramController( InstaService instaService, IHttpClientFactory httpClientFactory, IOptions <IrcConfig> ircConfig, ILogger <InstagramController> logger) { _instaService = instaService; _httpClientFactory = httpClientFactory; _logger = logger; _config = ircConfig.Value; }
public void TestSetup() { this.ircConfig = new IrcConfig(); this.ircConfig.Server = "irc.testdomain.com"; this.ircConfig.Channel = "#testchannel"; this.ircConfig.Port = 6667; this.ircConfig.Nick = "testbot"; this.ircConfig.UserName = "******"; this.ircConfig.RealName = "test bot"; this.ircConfig.Password = "******"; this.ircConfig.QuitMessage = "I am being shut down!"; }
public TestClient() { IrcConfig config = new IrcConfig("irc.seersirc.net", "TestClient"); config.Port = 6697; config.Ssl = true; config.Realname = "QuartzIrc Framework - Phate408"; Client = new IrcClient(config); Client.EventRawIn += new IrcRawEventHandler(OnRaw); }
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); }
public void TestSetup() { this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircWriter = new Mock <IIrcWriter>(MockBehavior.Strict); this.responseReceived = null; AllHandlerConfig allHandlerConfig = new AllHandlerConfig { AllAction = this.AllFunction }; this.uut = new AllHandler(allHandlerConfig); }
public void TestSetup() { this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircWriter = new Mock <IIrcWriter>(MockBehavior.Strict); this.responseReceived = null; PartHandlerConfig config = new PartHandlerConfig { PartAction = this.PartFunction }; this.uut = new PartHandler(config); }
public void TestSetup() { this.ircConfig = new IrcConfig(); this.ircConfig.Server = "irc.testdomain.com"; this.ircConfig.Channels.Add("#testchannel"); this.ircConfig.Port = 6667; this.ircConfig.UseSsl = false; this.ircConfig.Nick = "testbot"; this.ircConfig.UserName = "******"; this.ircConfig.RealName = "test bot"; this.ircConfig.QuitMessage = "I am being shut down!"; this.ircConfig.RateLimit = 800; }
public void TestSetup() { this.mockWriter = new Mock <IIrcWriter>(MockBehavior.Strict); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.Channels.Add("#channel2"); this.uut = new CrossChannelPlugin(); PluginInitor initor = new PluginInitor(); initor.IrcConfig = this.ircConfig; this.uut.Init(initor); }
public void TestSetup() { this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircWriter = new Mock <IIrcWriter>(MockBehavior.Strict); this.responseReceived = null; ConnectedEventConfig config = new ConnectedEventConfig { ConnectedAction = ConnectedFunction }; this.uut = new ConnectedEventHandler(config); }
public void TestSetup() { this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircWriter = new Mock <IIrcWriter>(MockBehavior.Strict); this.kickHandlerArgs = null; KickHandlerConfig kickHandlerConfig = new KickHandlerConfig { KickAction = this.KickHandler }; this.uut = new KickHandler(kickHandlerConfig); }
public void TestValidXmlWithJustChannelAndServer() { // Our expected behavior is everything but channel and server to be defaults. IrcConfig expectedConfig = new IrcConfig(); expectedConfig.Server = this.ircConfig.Server; expectedConfig.Channel = this.ircConfig.Channel; IIrcConfig config = XmlLoader.ParseIrcConfig( Path.Combine(testXmlFiles, "ValidIrcConfigJustChannelServer.xml") ); Assert.AreEqual(expectedConfig, config); }
public static IrcConfig GetTestIrcConfig() { IrcConfig ircConfig = new IrcConfig(); ircConfig.Server = "AServer"; ircConfig.Channel = "#AChannel"; ircConfig.Port = 1234; ircConfig.UserName = "******"; ircConfig.Nick = "SomeNick"; ircConfig.RealName = "Some Real Name"; ircConfig.Password = "******"; ircConfig.BridgeBots[BridgeBotUser] = @"(?<bridgeUser>\w+):\s+(?<bridgeMessage>.+)"; return(ircConfig); }
public void TestSetup() { this.mac = new Mock <IIrcMac>(MockBehavior.Strict); this.parsingQueue = new Mock <INonDisposableStringParsingQueue>(MockBehavior.Strict); this.defaultConfig = new IrcConfig { Nick = nick, QuitMessage = quitMessage, RealName = realName, UserName = userName, RateLimit = 0 }; defaultConfig.Channels.Add(channel1); defaultConfig.Channels.Add(channel2); }
// -------- Test Helpers -------- /// <summary> /// Ensures the three different types of IRC Configs are not equal. /// </summary> /// <param name="ircConfig">The IRC config object to test.</param> /// <param name="interfaceConfig">The interfaced IRC object to test.</param> /// <param name="roIrcConfig">The read-only IRC object to test.</param> private void CheckNotEqual( IrcConfig ircConfig, IIrcConfig interfaceConfig, ReadOnlyIrcConfig roIrcConfig ) { // Ensure not equals works going from real -> interface Assert.AreNotEqual( ircConfig, interfaceConfig ); Assert.AreNotEqual( interfaceConfig, ircConfig ); // Ensure not equals works going from real -> readonly Assert.AreNotEqual( ircConfig, roIrcConfig ); Assert.AreNotEqual( roIrcConfig, ircConfig ); // Ensure not equals works going from interface -> interface IIrcConfig iircConfig = ircConfig; Assert.AreNotEqual( iircConfig, interfaceConfig ); Assert.AreNotEqual( interfaceConfig, iircConfig ); // Ensure not equals works going from readonly -> readonly ReadOnlyIrcConfig roConfig = new ReadOnlyIrcConfig( ircConfig ); Assert.AreNotEqual( roConfig, roIrcConfig ); Assert.AreNotEqual( roIrcConfig, roConfig ); }
// ---------------- Functions ---------------- public static IrcConfig GetTestIrcConfig() { IrcConfig ircConfig = new IrcConfig(); ircConfig.Server = "AServer"; ircConfig.Channels.Add("#achannel"); ircConfig.Port = 1234; ircConfig.UseSsl = false; ircConfig.UserName = "******"; ircConfig.Nick = "SomeNick"; ircConfig.RealName = "Some Real Name"; ircConfig.ServerPassword = "******"; ircConfig.NickServPassword = "******"; ircConfig.BridgeBots[BridgeBotUser] = @"(?<bridgeUser>\w+):\s+(?<bridgeMessage>.+)"; ircConfig.Admins.Add("person1"); ircConfig.Admins.Add("person2"); ircConfig.RateLimit = 800; return(ircConfig); }
public void ConnectWithNoPasswordTest() { IrcConfig ircConfig = new IrcConfig { Nick = nick, QuitMessage = quitMessage, RealName = realName, UserName = userName, RateLimit = 0 }; ircConfig.Channels.Add(channel1); ircConfig.Channels.Add(channel2); using (IrcConnection connection = new IrcConnection(ircConfig, this.parsingQueue.Object, this.mac.Object)) { this.DoConnect(connection); this.DoDisconnect(connection); } this.mac.VerifyAll(); }
public void TestSetup() { this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircWriter = new Mock <IIrcWriter>(MockBehavior.Strict); this.responseReceived = null; }
public void ValidateTest() { // Ensure a valid config does not throw. Assert.DoesNotThrow(() => this.ircConfig.Validate()); Assert.DoesNotThrow(() => this.ircConfig.Clone().Validate()); // Tests Interface Assert.DoesNotThrow(() => new ReadOnlyIrcConfig(this.ircConfig).Validate()); // Tests Read-only // Empty bridge bots config should be valid. this.ircConfig.BridgeBots.Clear(); Assert.DoesNotThrow(() => this.ircConfig.Validate()); Assert.DoesNotThrow(() => this.ircConfig.Clone().Validate()); // Tests Interface Assert.DoesNotThrow(() => new ReadOnlyIrcConfig(this.ircConfig).Validate()); // Tests Read-only // Empty password should validate this.ircConfig.Password = string.Empty; Assert.DoesNotThrow(() => this.ircConfig.Validate()); Assert.DoesNotThrow(() => this.ircConfig.Clone().Validate()); // Tests Interface Assert.DoesNotThrow(() => new ReadOnlyIrcConfig(this.ircConfig).Validate()); // Tests Read-only // 160 characters on quit message is okay. this.ircConfig.QuitMessage = "1234567891123456789212345678931234567894123456789512345678961234567897123456789812345678991234567890123456789112345678921234567893123456789412345678951234567896"; Assert.DoesNotThrow(() => this.ircConfig.Validate()); Assert.DoesNotThrow(() => this.ircConfig.Clone().Validate()); // Tests Interface Assert.DoesNotThrow(() => new ReadOnlyIrcConfig(this.ircConfig).Validate()); // Tests Read-only // Change back. this.ircConfig = TestHelpers.GetTestIrcConfig(); // Now start changing stuff. this.ircConfig.Server = string.Empty; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.Channel = string.Empty; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.Port = -1; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.UserName = string.Empty; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.Nick = string.Empty; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.RealName = string.Empty; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); // Quit message more than 160 characters: this.ircConfig.QuitMessage = "12345678911234567892123456789312345678941234567895123456789612345678971234567898123456789912345678901234567891123456789212345678931234567894123456789512345678961"; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); // Quit message can not be null. this.ircConfig.QuitMessage = null; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); // No bridge message this.ircConfig.BridgeBots["telegrambot"] = @"(?<bridgeUser>\w+)-\s+(?<bridgeMsg>.+)"; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); // No bridge user this.ircConfig.BridgeBots["telegrambot"] = @"(?<bridgeUsr>\w+)-\s+(?<bridgeMessage>.+)"; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); // Empty string. this.ircConfig.BridgeBots["telegrambot"] = string.Empty; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); // null string. this.ircConfig.BridgeBots["telegrambot"] = null; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); // Empty key this.ircConfig.BridgeBots[string.Empty] = @"(?<bridgeUser>\w+)-\s+(?<bridgeMessage>.+)"; CheckNotValid(this.ircConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); }
/// <summary> /// Parses the given XML file and returns the IRC Config settings. /// </summary> /// <param name="fileName">The file name to parse.</param> /// <exception cref="FileNotFoundException">If the given filename does not exist.</exception> /// <exception cref="FormatException">If the port in the XML file is invalid.</exception> /// <exception cref="ApplicationException">If the irc config isn't valid.</exception> /// <returns>The IrcConfig objected based on the XML.</returns> public static IIrcConfig ParseIrcConfig(string fileName) { if (File.Exists(fileName) == false) { throw new FileNotFoundException("Could not find IRC Config file " + fileName); } XmlDocument doc = new XmlDocument(); doc.Load(fileName); XmlElement rootNode = doc.DocumentElement; if (rootNode.Name != ircConfigRootNodeName) { throw new XmlException( "Root XML node should be named \"" + ircConfigRootNodeName + "\". Got: " + rootNode.Name ); } IrcConfig config = new IrcConfig(); foreach (XmlNode childNode in rootNode.ChildNodes) { switch (childNode.Name) { case "server": config.Server = childNode.InnerText; break; case "channel": config.Channel = childNode.InnerText; break; case "port": config.Port = short.Parse(childNode.InnerText); break; case "username": config.UserName = childNode.InnerText; break; case "nick": config.Nick = childNode.InnerText; break; case "realname": config.RealName = childNode.InnerText; break; case "quitmessage": config.QuitMessage = childNode.InnerText; break; case "bridgebots": foreach (XmlNode bridgeBotNode in childNode.ChildNodes) { if (bridgeBotNode.Name == "bridgebot") { string botName = string.Empty; string botRegex = string.Empty; foreach (XmlAttribute attr in bridgeBotNode.Attributes) { switch (attr.Name) { case "botname": botName = attr.Value; break; case "botregex": botRegex = attr.Value; break; } } config.BridgeBots.Add(botName, botRegex); } } break; case "password": config.Password = childNode.InnerText; break; } } config.Validate(); return(config); }
public void TestSetup() { this.ircConfig = TestHelpers.GetTestIrcConfig(); ircConnection = new MockIrcConnection(this.ircConfig); responseReceived = null; }
public PerformToolActionPatch(IMonitor _monitor, IModHelper _helper, IrcConfig _config) { monitor = _monitor; helper = _helper; config = _config; }
public void TestSetup() { this.ircConfig = TestHelpers.GetTestIrcConfig(); }
public void EqualsTest() { IIrcConfig interfaceIrcConfig = this.ircConfig.Clone(); ReadOnlyIrcConfig roIrcConfig = new ReadOnlyIrcConfig(this.ircConfig.Clone()); // Ensure both the interface and the RO config are equal, but not the same reference. Assert.AreNotSame(interfaceIrcConfig, this.ircConfig); Assert.AreNotSame(roIrcConfig, this.ircConfig); Assert.AreNotSame(interfaceIrcConfig, roIrcConfig); // Ensure everything is equal. Assert.AreEqual(interfaceIrcConfig, this.ircConfig); Assert.AreEqual(this.ircConfig, interfaceIrcConfig); Assert.AreEqual(roIrcConfig, this.ircConfig); Assert.AreEqual(this.ircConfig, roIrcConfig); Assert.AreEqual(interfaceIrcConfig, roIrcConfig); Assert.AreEqual(roIrcConfig, interfaceIrcConfig); // BridgeBots should not be same reference. Assert.AreNotSame(interfaceIrcConfig.BridgeBots, this.ircConfig.BridgeBots); Assert.AreNotSame(roIrcConfig, this.ircConfig.BridgeBots); Assert.AreNotSame(interfaceIrcConfig.BridgeBots, roIrcConfig.BridgeBots); // Next, start changing things. Everything should become false. this.ircConfig.Server = "irc.somewhere.net"; CheckNotEqual(this.ircConfig, interfaceIrcConfig, roIrcConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.Channel = "#derp"; CheckNotEqual(this.ircConfig, interfaceIrcConfig, roIrcConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.Port = 9876; CheckNotEqual(this.ircConfig, interfaceIrcConfig, roIrcConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.UserName = "******"; CheckNotEqual(this.ircConfig, interfaceIrcConfig, roIrcConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.Nick = "Nate"; CheckNotEqual(this.ircConfig, interfaceIrcConfig, roIrcConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.RealName = "Nate A Saurus"; CheckNotEqual(this.ircConfig, interfaceIrcConfig, roIrcConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.Password = "******"; CheckNotEqual(this.ircConfig, interfaceIrcConfig, roIrcConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); this.ircConfig.QuitMessage = "A quit message"; CheckNotEqual(this.ircConfig, interfaceIrcConfig, roIrcConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); // Add an additional bot. this.ircConfig.BridgeBots["slackBridge"] = @"(?<bridgeUser>\w+):\s+(?<bridgeMessage>.+)"; CheckNotEqual(this.ircConfig, interfaceIrcConfig, roIrcConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); // Change an existing bot's value. this.ircConfig.BridgeBots["telegrambot"] = @"(?<bridgeUser>\w+)-\s+(?<bridgeMessage>.+)"; CheckNotEqual(this.ircConfig, interfaceIrcConfig, roIrcConfig); this.ircConfig = TestHelpers.GetTestIrcConfig(); }