/// <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; }
public void LoadMeta() { this.Controller = new SandboxProtocolController() { SandboxedProtocol = new MockIntegrationTestProtocol() }; this.Controller.AssignEvents(); }
public void TestFailureWhenAssemblyDoesNotExist() { var controller = new SandboxProtocolController(); controller.Create("Protocol.dll", this.Meta.ProtocolTypes.FirstOrDefault(type => type.Type == "MyrconTestProtocol8")); Assert.IsNull(controller.SandboxedProtocol); }
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); }
public void TestAttemptConnectionSandboxedNotNull() { var called = false; var controller = new SandboxProtocolController() { SandboxedProtocol = new MockIntegrationTestProtocol() { OnAttemptConnectionHandler = () => { called = true; } } }; controller.AttemptConnection(); Assert.IsTrue(called); }
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); }
public void TestActionSandboxedNull() { var controller = new SandboxProtocolController(); Assert.Null(controller.Action(null)); }
public void TestSynchronizeSandboxedNotNull() { var called = false; var controller = new SandboxProtocolController() { SandboxedProtocol = new MockIntegrationTestProtocol() { OnSynchronizeHandler = () => { called = true; } } }; controller.Synchronize(); Assert.IsTrue(called); }
public void TestStateSandboxedNull() { var controller = new SandboxProtocolController(); Assert.Null(controller.State); }
public void TestStateSandboxedNotNull() { IProtocolState state = new ProtocolState(); var controller = new SandboxProtocolController() { SandboxedProtocol = new MockIntegrationTestProtocol() { WaitingState = state } }; Assert.AreEqual(state, controller.State); }
public void TestClientSandboxedNull() { var controller = new SandboxProtocolController(); Assert.Null(controller.Client); }
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); }
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); }
public void TestProtocolTypeSandboxedNull() { var controller = new SandboxProtocolController(); Assert.Null(controller.ProtocolType); }
public void TestProtocolTypeSandboxedNotNull() { IProtocolType protocolType = new ProtocolType(); var controller = new SandboxProtocolController() { SandboxedProtocol = new MockIntegrationTestProtocol() { WaitingProtocolType = protocolType } }; Assert.AreEqual(protocolType, controller.ProtocolType); }
public void TestOptionsSandboxedNull() { var controller = new SandboxProtocolController(); Assert.Null(controller.Options); }
public void TestOptionsSandboxedNotNull() { IProtocolSetup options = new ProtocolSetup(); var controller = new SandboxProtocolController() { SandboxedProtocol = new MockIntegrationTestProtocol() { WaitingOptions = options } }; Assert.AreEqual(options, controller.Options); }
public void TestFailureWhenProtocolProviderDoesNotExist() { var controller = new SandboxProtocolController(); controller.Create(this.Meta.Assembly.FullName, new ProtocolType() { Provider = "Fake", Type = "MyrconTestProtocol8" }); Assert.IsNull(controller.SandboxedProtocol); }
public void TestClientSandboxedNotNull() { IClient client = new MockClient(); var controller = new SandboxProtocolController() { SandboxedProtocol = new MockIntegrationTestProtocol() { WaitingClient = client } }; Assert.AreEqual(client, controller.Client); }
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); }
public void TestSetupSandboxedNull() { var controller = new SandboxProtocolController(); Assert.Null(controller.Setup(null)); }
public void TestShutdownSandboxedNulledAfterShutdown() { var controller = new SandboxProtocolController() { SandboxedProtocol = new MockIntegrationTestProtocol() }; controller.Shutdown(); Assert.IsNull(controller.SandboxedProtocol); }