Beispiel #1
0
        private static TestPlugin GetTestPlugin()
        {
            var manager = new PluginManager();
            var plugin  = new TestPlugin();

            plugin.Manager = manager;
            manager.Plugins.Add(plugin);

            return(plugin);
        }
Beispiel #2
0
        public void StringCommandTest()
        {
            // arrange
            TestPlugin plugin = GetTestPlugin();
            MethodInfo method = plugin.GetMethodInfo(nameof(TestPlugin.CmdString));

            // act
            bool successful = plugin.Manager.ExecuteCommand(method, new Player(null, null), new[] { "text" }, out object result);

            // assert
            Assert.IsTrue(successful);
            Assert.AreEqual("text", result);
        }
Beispiel #3
0
        public void RelValueCommandTest()
        {
            // arrange
            TestPlugin plugin = GetTestPlugin();
            MethodInfo method = plugin.GetMethodInfo(nameof(TestPlugin.CmdRelValue));

            // act
            bool successful = plugin.Manager.ExecuteCommand(method, new Player(null, null), new[] { "1.2", "~3.4" }, out object result);

            // assert
            Assert.IsTrue(successful);
            Assert.AreEqual("Value: 1.2, Relative: False, Value: 3.4, Relative: True", result);
        }
Beispiel #4
0
        public void EntityPosCommandTest()
        {
            // arrange
            TestPlugin plugin = GetTestPlugin();
            MethodInfo method = plugin.GetMethodInfo(nameof(TestPlugin.CmdEntityPos));

            // act
            bool successful = plugin.Manager.ExecuteCommand(method, new Player(null, null), new[] { "1.2", "3.4", "~5.6" }, out object result);

            // assert
            Assert.IsTrue(successful);
            Assert.AreEqual("X: 1.2, XRelative: False, Y: 3.4, YRelative: False, Z: 5.6, ZRelative: True", result);
        }