Exemplo n.º 1
0
        public async Task TestPluginExports()
        {
            const string pluginPath = "/path/to/plugin.sln";
            var          api        = new NvimAPI();
            await PluginHost.RegisterPlugin <TestPlugin>(api, pluginPath);

            await api.Command(
                $"let g:result = {nameof(TestPlugin.AddNumbers)}(1, 2)");

            var result = await api.GetVar("result");

            Assert.AreEqual(3L, result);

            await api.Command($"{nameof(TestPlugin.TestCommand1)} a b c");

            CollectionAssert.AreEqual(new[] { "a", "b", "c" }, TestPlugin.Command1Args);

            await api.Command($"{nameof(TestPlugin.TestCommand2)} 1 2 3");

            Assert.AreEqual("1 2 3", TestPlugin.Command2Args);

            await api.Command("edit test.cs");

            Assert.IsTrue(TestPlugin.AutocmdCalled);

            await api.Command($"call {nameof(TestPlugin.CountLines)}()");

            Assert.IsTrue(TestPlugin.CountLinesReturn == 1);
        }
Exemplo n.º 2
0
        public async Task TestCallAndReply()
        {
            var api = new NvimAPI();

            api.RegisterHandler("client-call", args =>
            {
                CollectionAssert.AreEqual(new[] { 1L, 2L, 3L }, args);
                return(new[] { 4, 5, 6 });
            });
            var objects = await api.GetApiInfo();

            var channelID = (long)objects.First();
            await api.Command(
                $"let g:result = rpcrequest({channelID}, 'client-call', 1, 2, 3)");

            var result = (object[])await api.GetVar("result");

            CollectionAssert.AreEqual(new[] { 4L, 5L, 6L }, result);
        }