当前位置: 首页>>代码示例>>C#>>正文


C# PluginManager.StartAsync方法代码示例

本文整理汇总了C#中PluginManager.StartAsync方法的典型用法代码示例。如果您正苦于以下问题:C# PluginManager.StartAsync方法的具体用法?C# PluginManager.StartAsync怎么用?C# PluginManager.StartAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PluginManager的用法示例。


在下文中一共展示了PluginManager.StartAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestPropertyUpdatingOnDatabaseSettingChange

        public async Task TestPropertyUpdatingOnDatabaseSettingChange()
        {
            //Arrange 
            var dbConnection = new UnitTestDbConnection();
            Database.SetInitializer(new CreateFreshDbInitializer());

            var log = new StubIFeedback<LogEntry>
            {
                ReportAsyncT0CancellationToken = (e, c) =>
                {
                    Console.WriteLine(e.ToString());
                    return Task.FromResult(0);
                }
            };
            var unitTestingPlugin = new StubUnitTestPlugin
            {
                PluginGuidGet = () => Guid.Parse("a0f912a6-b8bb-406a-360f-1eb13f50aae4"),
                NameGet = () => "Unit Testing Plugin",
                DescriptionGet = () => "",
                OnSettingsCreatingPluginSettingBuilder = s => Task.FromResult(0),
                OnDeviceSettingsCreatingDeviceSettingBuilder = s => Task.FromResult(0),
                OnSceneSettingsCreatingSceneSettingBuilder = s => Task.FromResult(0),
            };

            var plugin = new Plugin
            {
                PluginGuid = Guid.Parse("a0f912a6-b8bb-406a-360f-1eb13f50aae4"),
                Name = "Unit Testing Plugin",
                Description = ""
            };
            plugin.Settings.Add(new PluginSetting
            {
                UniqueIdentifier = "PropertyTest",
                Value = "2",
                ValueType = DataType.INTEGER
            });

            using (var context = new ZvsContext(dbConnection))
            {
                context.Plugins.Add(plugin);
                await context.SaveChangesAsync(CancellationToken.None);
            }

            var pluginManager = new PluginManager(new List<ZvsPlugin> { unitTestingPlugin }, dbConnection, log, new StubIAdapterManager());
            await pluginManager.StartAsync(CancellationToken.None);
            //act
            using (var context = new ZvsContext(dbConnection))
            {
                context.PluginSettings.First().Value = "55";
                await context.SaveChangesAsync(CancellationToken.None);
            }

            //assert 
            Assert.IsTrue(unitTestingPlugin.PropertyTest == 55, "The property test property on the zvsPlugin did not properly update when the database value was changed.");
        }
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:55,代码来源:PluginManagerTests.cs

示例2: FindZvsPluginInvalidIdAsyncTest

        public async Task FindZvsPluginInvalidIdAsyncTest()
        {
            //Arrange 
            var dbConnection = new UnitTestDbConnection();
            Database.SetInitializer(new CreateFreshDbInitializer());

            var logEntries = new List<LogEntry>();
            var log = new StubIFeedback<LogEntry>
            {
                ReportAsyncT0CancellationToken = (e, c) =>
                {
                    Console.WriteLine(e.ToString());
                    logEntries.Add(e);
                    return Task.FromResult(0);
                }
            };

            var pluginManager = new PluginManager(new List<ZvsPlugin>(), dbConnection, log, new StubIAdapterManager());
            await pluginManager.StartAsync(CancellationToken.None);

            //act
            var plugin = pluginManager.FindZvsPlugin(1);

            //assert 
            Assert.IsNull(plugin, "Found a plugin?");
        }
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:26,代码来源:PluginManagerTests.cs

示例3: LoadPluginsAsyncAutoStartTest

        public async Task LoadPluginsAsyncAutoStartTest()
        {
            //Arrange 
            var dbConnection = new UnitTestDbConnection();
            Database.SetInitializer(new CreateFreshDbInitializer());

            var log = new StubIFeedback<LogEntry>
            {
                ReportAsyncT0CancellationToken = (e, c) =>
                {
                    Console.WriteLine(e.ToString());
                    return Task.FromResult(0);
                }
            };

            var plugin = new Plugin()
            {
                PluginGuid = Guid.Parse("a0f912a6-b8bb-406a-360f-1eb13f50aae4"),
                IsEnabled = true
            };
            using (var context = new ZvsContext(dbConnection))
            {
                context.Plugins.Add(plugin);
                await context.SaveChangesAsync(CancellationToken.None);
            }
            var isStarted = false;
            var unitTestingPlugin = new StubUnitTestPlugin
            {
                PluginGuidGet = () => Guid.Parse("a0f912a6-b8bb-406a-360f-1eb13f50aae4"),
                NameGet = () => "Unit Testing Plugin",
                DescriptionGet = () => "",
                OnSettingsCreatingPluginSettingBuilder = s => Task.FromResult(0),
                OnDeviceSettingsCreatingDeviceSettingBuilder = s => Task.FromResult(0),
                OnSceneSettingsCreatingSceneSettingBuilder = s => Task.FromResult(0),
                StartAsync01 = () =>
                {
                    isStarted = true;
                    return Task.FromResult(0);
                }
            };
            unitTestingPlugin.OnSettingsCreatingPluginSettingBuilder = async settingBuilder =>
            {
                var testSetting = new PluginSetting
                {
                    Name = "Test setting",
                    Value = 360.ToString(CultureInfo.InvariantCulture),
                    ValueType = DataType.INTEGER,
                    Description = "Unit testing only"
                };

                await
                    settingBuilder.Plugin(unitTestingPlugin)
                        .RegisterPluginSettingAsync(testSetting, o => o.PropertyTest);
            };

            var pluginManager = new PluginManager(new List<ZvsPlugin> { unitTestingPlugin }, dbConnection, log, new StubIAdapterManager());

            //act
            await pluginManager.StartAsync(CancellationToken.None);

            //assert 
            Assert.IsTrue(isStarted, "Plugin not started!");
        }
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:63,代码来源:PluginManagerTests.cs

示例4: FindZvsPluginAsyncTest

        public async Task FindZvsPluginAsyncTest()
        {
            //Arrange 
            var dbConnection = new UnitTestDbConnection();
            Database.SetInitializer(new CreateFreshDbInitializer());

            var logEntries = new List<LogEntry>();
            var log = new StubIFeedback<LogEntry>
            {
                ReportAsyncT0CancellationToken = (e, c) =>
                {
                    Console.WriteLine(e.ToString());
                    logEntries.Add(e);
                    return Task.FromResult(0);
                }
            };

            var unitTestingPlugin = new StubUnitTestPlugin
            {
                PluginGuidGet = () => Guid.Parse("a0f912a6-b8bb-406a-360f-1eb13f50aae4"),
                NameGet = () => "Unit Testing Plugin",
                DescriptionGet = () => "",
                OnSettingsCreatingPluginSettingBuilder = s => Task.FromResult(0),
                OnDeviceSettingsCreatingDeviceSettingBuilder = s => Task.FromResult(0),
                OnSceneSettingsCreatingSceneSettingBuilder = s => Task.FromResult(0)
            };

            var pluginManager = new PluginManager(new List<ZvsPlugin> { unitTestingPlugin }, dbConnection, log, new StubIAdapterManager());
            await pluginManager.StartAsync(CancellationToken.None);

            //act
            var plugin = pluginManager.FindZvsPlugin(1);
            

            //assert 
            Assert.IsNotNull(plugin, "Registered plugin not found!");
            Assert.IsTrue(plugin.PluginGuid == unitTestingPlugin.PluginGuid, "Found wrong plugin!");
        }
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:38,代码来源:PluginManagerTests.cs

示例5: LoadPluginsNameTooLongAsyncTest

        public async Task LoadPluginsNameTooLongAsyncTest()
        {
            //Arrange 
            var dbConnection = new UnitTestDbConnection();
            Database.SetInitializer(new CreateFreshDbInitializer());

            var logEntries = new List<LogEntry>();
            var log = new StubIFeedback<LogEntry>
            {
                ReportAsyncT0CancellationToken = (e, c) =>
                {
                    Console.WriteLine(e.ToString());
                    logEntries.Add(e);
                    return Task.FromResult(0);
                }
            };

            var longNamePlugin = new StubZvsPlugin
            {
                PluginGuidGet = () => Guid.Parse("a0f912a6-b8bb-406a-360f-1eb13f50aae4"),
                NameGet = () => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque magna diam, pellentesque et orci eget, pellentesque iaculis odio. Ut ultrices est sapien, ac pellentesque odio malesuada a. Etiam in neque ullamcorper massa gravida ullamcorper vel a posuere.",
                DescriptionGet = () => "",
                OnSettingsCreatingPluginSettingBuilder = s => Task.FromResult(0),
                OnDeviceSettingsCreatingDeviceSettingBuilder = s => Task.FromResult(0),
                OnSceneSettingsCreatingSceneSettingBuilder = s => Task.FromResult(0)
            };

            var pluginManager = new PluginManager(new List<ZvsPlugin>() { longNamePlugin }, dbConnection, log, new StubIAdapterManager());
            //act
            await pluginManager.StartAsync(CancellationToken.None);

            //assert 
            Assert.IsTrue(logEntries.Count(o => o.Level == LogEntryLevel.Error) == 1, "Expected 1 error");
        }
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:34,代码来源:PluginManagerTests.cs

示例6: StopTest

        public async Task StopTest()
        {
            //Arrange 
            var dbConnection = new StubIEntityContextConnection { NameOrConnectionStringGet = () => "am-StopTest" };
            Database.SetInitializer(new CreateFreshDbInitializer());
            var logEntries = new List<LogEntry>();
            var log = new StubIFeedback<LogEntry>
            {
                ReportAsyncT0CancellationToken = (e, c) =>
                {
                    logEntries.Add(e);
                    Console.WriteLine(e.ToString());
                    return Task.FromResult(0);
                }
            };

            var plugin = new Plugin()
            {
                PluginGuid = Guid.Parse("a0f912a6-b8bb-406a-360f-1eb13f50aae4"),
                IsEnabled = true
            };
            using (var context = new ZvsContext(dbConnection))
            {
                context.Plugins.Add(plugin);
                await context.SaveChangesAsync(CancellationToken.None);
            }
            var isStartedCount = 0;
            var isStoppedCount = 0;
            var unitTestingPlugin = new StubUnitTestPlugin
            {
                PluginGuidGet = () => Guid.Parse("a0f912a6-b8bb-406a-360f-1eb13f50aae4"),
                NameGet = () => "Unit Testing Plugin",
                DescriptionGet = () => "",
                OnSettingsCreatingPluginSettingBuilder = (s) => Task.FromResult(0),
                OnDeviceSettingsCreatingDeviceSettingBuilder = (s) => Task.FromResult(0),
                OnSceneSettingsCreatingSceneSettingBuilder = (s) => Task.FromResult(0),
                StartAsync01 = () =>
                {
                    isStartedCount++;
                    return Task.FromResult(0);
                },
                StopAsync01 = () =>
                {
                    isStoppedCount++;
                    return Task.FromResult(0);
                }
            };
            unitTestingPlugin.OnSettingsCreatingPluginSettingBuilder = async (settingBuilder) =>
            {
                var testSetting = new PluginSetting
                {
                    Name = "Test setting",
                    Value = 360.ToString(CultureInfo.InvariantCulture),
                    ValueType = DataType.INTEGER,
                    Description = "Unit testing only"
                };

                await
                    settingBuilder.Plugin(unitTestingPlugin)
                        .RegisterPluginSettingAsync(testSetting, o => o.PropertyTest);
            };

            var pluginManager = new PluginManager(new List<ZvsPlugin> { unitTestingPlugin }, dbConnection, log, new StubIAdapterManager());

            //act
            await pluginManager.StartAsync(CancellationToken.None);
            await pluginManager.StopAsync(CancellationToken.None);

            //assert 
            Assert.IsTrue(logEntries.All(o => o.Level == LogEntryLevel.Info), "Not all log entries are info level");
            Assert.IsTrue(isStartedCount == 1, "Plugin started too many or too few times");
            Assert.IsTrue(isStoppedCount == 1, "Plugin stopped too many or too few times");
        }
开发者ID:m19brandon,项目名称:zVirtualScenes,代码行数:73,代码来源:PluginManagerTests.cs


注:本文中的PluginManager.StartAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。