コード例 #1
0
ファイル: TestTextCommands.cs プロジェクト: EBassie/Potato
        /// <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;
        }
コード例 #2
0
ファイル: TestBubble.cs プロジェクト: EBassie/Potato
        public void LoadMeta()
        {
            this.Controller = new SandboxProtocolController() {
                SandboxedProtocol = new MockIntegrationTestProtocol()
            };

            this.Controller.AssignEvents();
        }
コード例 #3
0
ファイル: TestCreate.cs プロジェクト: EBassie/Potato
        public void TestFailureWhenAssemblyDoesNotExist()
        {
            var controller = new SandboxProtocolController();

            controller.Create("Protocol.dll", this.Meta.ProtocolTypes.FirstOrDefault(type => type.Type == "MyrconTestProtocol8"));

            Assert.IsNull(controller.SandboxedProtocol);
        }
コード例 #4
0
ファイル: TestCreate.cs プロジェクト: EBassie/Potato
        public void TestFailureReturnsFalse()
        {
            var controller = new SandboxProtocolController();

            var result = controller.Create("Protocol.dll", this.Meta.ProtocolTypes.FirstOrDefault(type => type.Type == "MyrconTestProtocol8"));

            Assert.IsFalse(result);
            Assert.IsNull(controller.SandboxedProtocol);
        }
コード例 #5
0
        public void TestAttemptConnectionSandboxedNotNull()
        {
            var called = false;

            var controller = new SandboxProtocolController() {
                SandboxedProtocol = new MockIntegrationTestProtocol() {
                    OnAttemptConnectionHandler = () => {
                        called = true;
                    }
                }
            };

            controller.AttemptConnection();

            Assert.IsTrue(called);
        }
コード例 #6
0
        public void TestActionSandboxedNotNull()
        {
            var called = false;

            var controller = new SandboxProtocolController() {
                SandboxedProtocol = new MockIntegrationTestProtocol() {
                    OnActionHandler = action => {
                        called = true;

                        return new List<IPacket>();
                    }
                }
            };

            controller.Action(null);

            Assert.IsTrue(called);
        }
コード例 #7
0
        public void TestActionSandboxedNull()
        {
            var controller = new SandboxProtocolController();

            Assert.Null(controller.Action(null));
        }
コード例 #8
0
        public void TestSynchronizeSandboxedNotNull()
        {
            var called = false;

            var controller = new SandboxProtocolController() {
                SandboxedProtocol = new MockIntegrationTestProtocol() {
                    OnSynchronizeHandler = () => {
                        called = true;
                    }
                }
            };

            controller.Synchronize();

            Assert.IsTrue(called);
        }
コード例 #9
0
        public void TestStateSandboxedNull()
        {
            var controller = new SandboxProtocolController();

            Assert.Null(controller.State);
        }
コード例 #10
0
        public void TestStateSandboxedNotNull()
        {
            IProtocolState state = new ProtocolState();

            var controller = new SandboxProtocolController() {
                SandboxedProtocol = new MockIntegrationTestProtocol() {
                    WaitingState = state
                }
            };

            Assert.AreEqual(state, controller.State);
        }
コード例 #11
0
        public void TestClientSandboxedNull()
        {
            var controller = new SandboxProtocolController();

            Assert.Null(controller.Client);
        }
コード例 #12
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);
        }
コード例 #13
0
        public void TestSendSandboxedNotNull()
        {
            var called = false;

            var controller = new SandboxProtocolController() {
                SandboxedProtocol = new MockIntegrationTestProtocol() {
                    OnSendHandler = packet => {
                        called = true;

                        return new Packet();
                    }
                }
            };

            controller.Send(null);

            Assert.IsTrue(called);
        }
コード例 #14
0
        public void TestProtocolTypeSandboxedNull()
        {
            var controller = new SandboxProtocolController();

            Assert.Null(controller.ProtocolType);
        }
コード例 #15
0
        public void TestProtocolTypeSandboxedNotNull()
        {
            IProtocolType protocolType = new ProtocolType();

            var controller = new SandboxProtocolController() {
                SandboxedProtocol = new MockIntegrationTestProtocol() {
                    WaitingProtocolType = protocolType
                }
            };

            Assert.AreEqual(protocolType, controller.ProtocolType);
        }
コード例 #16
0
        public void TestOptionsSandboxedNull()
        {
            var controller = new SandboxProtocolController();

            Assert.Null(controller.Options);
        }
コード例 #17
0
        public void TestOptionsSandboxedNotNull()
        {
            IProtocolSetup options = new ProtocolSetup();

            var controller = new SandboxProtocolController() {
                SandboxedProtocol = new MockIntegrationTestProtocol() {
                    WaitingOptions = options
                }
            };

            Assert.AreEqual(options, controller.Options);
        }
コード例 #18
0
ファイル: TestCreate.cs プロジェクト: EBassie/Potato
        public void TestFailureWhenProtocolProviderDoesNotExist()
        {
            var controller = new SandboxProtocolController();

            controller.Create(this.Meta.Assembly.FullName, new ProtocolType() {
                Provider = "Fake",
                Type = "MyrconTestProtocol8"
            });

            Assert.IsNull(controller.SandboxedProtocol);
        }
コード例 #19
0
        public void TestClientSandboxedNotNull()
        {
            IClient client = new MockClient();

            var controller = new SandboxProtocolController() {
                SandboxedProtocol = new MockIntegrationTestProtocol() {
                    WaitingClient = client
                }
            };

            Assert.AreEqual(client, controller.Client);
        }
コード例 #20
0
ファイル: TestCreate.cs プロジェクト: EBassie/Potato
        public void TestSuccessReturnsTrue()
        {
            var controller = new SandboxProtocolController();

            var result = controller.Create(this.Meta.Assembly.FullName, this.Meta.ProtocolTypes.FirstOrDefault(type => type.Type == "MyrconTestProtocol8"));

            Assert.IsTrue(result);
            Assert.IsNotNull(controller.SandboxedProtocol);
        }
コード例 #21
0
        public void TestSetupSandboxedNull()
        {
            var controller = new SandboxProtocolController();

            Assert.Null(controller.Setup(null));
        }
コード例 #22
0
        public void TestShutdownSandboxedNulledAfterShutdown()
        {
            var controller = new SandboxProtocolController() {
                SandboxedProtocol = new MockIntegrationTestProtocol()
            };

            controller.Shutdown();

            Assert.IsNull(controller.SandboxedProtocol);
        }