本文整理汇总了C#中Operations.GetFunc方法的典型用法代码示例。如果您正苦于以下问题:C# Operations.GetFunc方法的具体用法?C# Operations.GetFunc怎么用?C# Operations.GetFunc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operations
的用法示例。
在下文中一共展示了Operations.GetFunc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Func_With_1_Args_InvokeWithNoRetry
public void Func_With_1_Args_InvokeWithNoRetry()
{
// arrange
Operations operations = new Operations(0);
var policy = Policy.NoRetry();
var func = operations.GetFunc<int, int>();
// act
func.InvokeWithRetry(policy.RetryPolicy, 0);
// assert
Assert.Equal(0, policy.ShouldRetryCallCount);
Assert.Equal(0, operations.ThrowCount);
Assert.Equal(1, operations.ExecuteCount);
}
示例2: Func_will_throw_when_policy_returns_false
public void Func_will_throw_when_policy_returns_false()
{
// arrange
Operations operations = new Operations(1);
var policy = Policy.NoRetry();
var func = operations.GetFunc<int>();
Assert.ThrowsDelegate testCode = () => func.InvokeWithRetry(policy.RetryPolicy);
// act
Exception exception = Assert.Throws<Exception>(testCode);
// assert
Assert.Equal(1, policy.ShouldRetryCallCount);
Assert.Equal(string.Format(Operations.ExceptionMessageFormat, 1), exception.Message);
Assert.Equal(1, operations.ThrowCount);
Assert.Equal(1, operations.ExecuteCount);
}
示例3: Func_With_9_Args_InvokeWithNoRetry
public void Func_With_9_Args_InvokeWithNoRetry()
{
// arrange
Operations operations = new Operations(0);
var func = operations.GetFunc<int,int,int,int,int,int,int,int,int,int>();
// act
func.InvokeWithRetry(RetryPolicies.NoRetry(),0,0,0,0,0,0,0,0,0);
// assert
Assert.Equal(0, operations.ThrowCount);
Assert.Equal(1, operations.ExecuteCount);
}