コード例 #1
0
 public void TestSetup()
 {
     this.ircConfig   = TestHelpers.GetTestIrcConfig();
     ircConnection    = new MockIrcConnection(this.ircConfig);
     responseReceived = null;
     this.uut         = new PartHandler(PartFunction);
 }
コード例 #2
0
        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();
        }
コード例 #3
0
        public void TestSetup()
        {
            this.ircConfig = TestHelpers.GetTestIrcConfig();
            this.ircWriter = new Mock <IIrcWriter>(MockBehavior.Strict);

            this.uut = new PongHandler();
        }
コード例 #4
0
        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;
        }
コード例 #5
0
ファイル: IrcConnector.cs プロジェクト: alexhorner/smIRCL
        /// <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();
            }
        }
コード例 #6
0
ファイル: IrcConfigTest.cs プロジェクト: Stefancanvas/Chaskis
        /// <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() );
        }
コード例 #7
0
        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();
        }
コード例 #8
0
 public InstagramController(
     InstaService instaService,
     IHttpClientFactory httpClientFactory,
     IOptions <IrcConfig> ircConfig,
     ILogger <InstagramController> logger)
 {
     _instaService      = instaService;
     _httpClientFactory = httpClientFactory;
     _logger            = logger;
     _config            = ircConfig.Value;
 }
コード例 #9
0
 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!";
 }
コード例 #10
0
ファイル: TestClient.cs プロジェクト: bitsrc/QuartzIrc
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 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;
 }
コード例 #15
0
        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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        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);
        }
コード例 #21
0
ファイル: IrcConfigTest.cs プロジェクト: Stefancanvas/Chaskis
        // -------- 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 );
        }
コード例 #22
0
        // ---------------- 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);
        }
コード例 #23
0
        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();
        }
コード例 #24
0
 public void TestSetup()
 {
     this.ircConfig        = TestHelpers.GetTestIrcConfig();
     this.ircWriter        = new Mock <IIrcWriter>(MockBehavior.Strict);
     this.responseReceived = null;
 }
コード例 #25
0
        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();
        }
コード例 #26
0
ファイル: XmlLoader.cs プロジェクト: noisynoise/Chaskis
        /// <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);
        }
コード例 #27
0
 public void TestSetup()
 {
     this.ircConfig   = TestHelpers.GetTestIrcConfig();
     ircConnection    = new MockIrcConnection(this.ircConfig);
     responseReceived = null;
 }
コード例 #28
0
 public PerformToolActionPatch(IMonitor _monitor, IModHelper _helper, IrcConfig _config)
 {
     monitor = _monitor;
     helper  = _helper;
     config  = _config;
 }
コード例 #29
0
 public void TestSetup()
 {
     this.ircConfig = TestHelpers.GetTestIrcConfig();
 }
コード例 #30
0
        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();
        }