本文整理匯總了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);
}