Exemplo n.º 1
0
        /// <summary>
        /// Creates a connection object with a MockGame, including players and maps etc.
        /// </summary>
        /// <remarks>The plugin will be enabled during this process.</remarks>
        /// <returns></returns>
        protected ConnectionController CreateConnection() {
            ISandboxProtocolController protocol = new SandboxProtocolController() {
                SandboxedProtocol = new MockGame()
            };

            protocol.Setup(new ProtocolSetup() {
                Hostname = "localhost",
                Port = 9000
            });

            ConnectionController connection = new ConnectionController() {
                // This won't actually connect to anything.
                // It's just a mock so the GameState is available to be modified.
                // See MockGame for all the mock data we create.
                Protocol = protocol
            };

            // 1. When this is called you will see the constructor in the plugin executed.
            // Potato.Examples.TextCommands.Program 
            connection.Execute();

            // Note: Enable the single plugin that was loaded, otherwise it won't recieve any tunneled commands or events.

            // 2. When this is executed you will see a GenericEvent fired. Place your breakpoint in
            // Potato.Examples.TextCommands.Program.GenericEvent -> PluginsPluginEnabled
            connection.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.PluginsEnable,
                Scope = {
                    PluginGuid = connection.Plugins.LoadedPlugins.First().PluginGuid
                }
            });

            return connection;
        }
Exemplo n.º 2
0
        public void TestSetupSandboxedNull()
        {
            var controller = new SandboxProtocolController();

            Assert.Null(controller.Setup(null));
        }
Exemplo n.º 3
0
        public void TestSetupSandboxedNotNull()
        {
            var called = false;

            var controller = new SandboxProtocolController() {
                SandboxedProtocol = new MockIntegrationTestProtocol() {
                    OnSetupHandler = setup => {
                        called = true;

                        return new ProtocolSetupResult();
                    }
                }
            };

            controller.Setup(null);

            Assert.IsTrue(called);
        }