本文整理汇总了C#中PluginManager.SetPluginProperty方法的典型用法代码示例。如果您正苦于以下问题:C# PluginManager.SetPluginProperty方法的具体用法?C# PluginManager.SetPluginProperty怎么用?C# PluginManager.SetPluginProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PluginManager
的用法示例。
在下文中一共展示了PluginManager.SetPluginProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetPluginPropertyCastPropertyTest
public async Task SetPluginPropertyCastPropertyTest()
{
//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();
var pluginManager = new PluginManager(new List<ZvsPlugin> { unitTestingPlugin }, dbConnection, log, new StubIAdapterManager());
//act
await pluginManager.SetPluginProperty(unitTestingPlugin, "PropertyTest", "abc", CancellationToken.None);
//assert
Assert.IsTrue(unitTestingPlugin.PropertyTest == 0, "Expected TestSetting property to be 0");
Assert.IsTrue(logEntries.Count(o => o.Level == LogEntryLevel.Error && o.Message.Contains("Cannot cast value")) == 1, "Expected 1 cannot cast value on plugin setting error");
}
示例2: SetPluginPropertyTest
public async Task SetPluginPropertyTest()
{
//Arrange
var dbConnection = new StubIEntityContextConnection { NameOrConnectionStringGet = () => "am-SetPluginPropertyTest" };
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();
var pluginManager = new PluginManager(new List<ZvsPlugin> { unitTestingPlugin }, dbConnection, log, new StubIAdapterManager());
//act
await pluginManager.SetPluginProperty(unitTestingPlugin, "PropertyTest", "360", CancellationToken.None);
//assert
Assert.IsTrue(logEntries.Count(o => o.Level == LogEntryLevel.Error) == 0, "Expected 0 errors");
Assert.IsTrue(unitTestingPlugin.PropertyTest == 360, "Expected TestSetting property to be 360");
}