本文整理汇总了C#中InMemoryAdapter.AddFunction方法的典型用法代码示例。如果您正苦于以下问题:C# InMemoryAdapter.AddFunction方法的具体用法?C# InMemoryAdapter.AddFunction怎么用?C# InMemoryAdapter.AddFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InMemoryAdapter
的用法示例。
在下文中一共展示了InMemoryAdapter.AddFunction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcedureReturningArrayShouldWork
public void ProcedureReturningArrayShouldWork()
{
var adapter = new InMemoryAdapter();
adapter.AddFunction("Test", () => new[] { new Dictionary<string, object> { { "Foo", "Bar" } } });
Database.UseMockAdapter(adapter);
var db = Database.Open();
foreach (var row in db.Test())
{
Assert.AreEqual("Bar", row.Foo);
}
}
示例2: ProcedureWithParametersReturningArrayShouldWork
public void ProcedureWithParametersReturningArrayShouldWork()
{
var adapter = new InMemoryAdapter();
adapter.AddFunction<string, object, IDictionary<string, object>[]>("Test", (key, value) => new IDictionary<string, object>[] {new Dictionary<string, object> { { key, value } }});
Database.UseMockAdapter(adapter);
var db = Database.Open();
foreach (var row in db.Test("Foo", "Bar"))
{
Assert.AreEqual("Bar", row.Foo);
}
}
示例3: CanSimulateProcedureWithOutputParameters
public void CanSimulateProcedureWithOutputParameters()
{
const string key = "outparam";
const string value = "outParamValue";
var adapter = new InMemoryAdapter();
adapter.AddFunction("Test", p =>
{
p.Add(key, value);
return p;
});
Database.UseMockAdapter(adapter);
var db = Database.Open();
var result = db.Test();
Assert.That(result.OutputValues[key], Is.EqualTo(value));
}