本文整理汇总了C#中Promise.Success方法的典型用法代码示例。如果您正苦于以下问题:C# Promise.Success方法的具体用法?C# Promise.Success怎么用?C# Promise.Success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Promise
的用法示例。
在下文中一共展示了Promise.Success方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestBasicPromise
public void TestBasicPromise()
{
Promise<int> p1 = new Promise<int>(cb => cb(null, 5));
bool test = false;
p1.Success(s => test = true);
p1.Success(s => Assert.AreEqual(s, 5));
Assert.IsTrue(test);
}
示例2: TestFailure
public void TestFailure()
{
Promise<long> p = new Promise<long>(cb => cb("uh oh", default(long)));
bool test = false;
p.Success(x => test = true);
Assert.IsFalse(test);
p.Fail(s => test = true);
Assert.IsTrue(test);
var p2 = p.FlatMap(l => new Promise<int>(cb => cb(null, 3)));
test = false;
p2.Success(x => test = true);
Assert.IsFalse(test);
p2.Fail(s => test = true);
Assert.IsTrue(test);
}
示例3: TestJoin
public void TestJoin()
{
Promise<Promise<string>> p = new Promise<Promise<string>>(cb => cb(null, new Promise<string>(cb2 => cb2(null, "gotcha"))));
p.Success(s => Assert.AreNotEqual(s, "gotcha"));
p.Success(s => s.Success(y => Assert.AreEqual(y, "gotcha")));
var p2 = Promise.Join(p);
p2.Success(s => Assert.AreEqual(s, "gotcha"));
bool test = false;
p2.Success(x => test = true);
Assert.IsTrue(test);
}