本文整理汇总了C#中Mock.ExecuteAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.ExecuteAsync方法的具体用法?C# Mock.ExecuteAsync怎么用?C# Mock.ExecuteAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mock
的用法示例。
在下文中一共展示了Mock.ExecuteAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteAsync_Func_throws_on_null_parameters
public void ExecuteAsync_Func_throws_on_null_parameters()
{
var mockExecutionStrategy =
new Mock<DbExecutionStrategy>
{
CallBase = true
}.Object;
Assert.Equal(
"operation",
Assert.Throws<ArgumentNullException>(
() => mockExecutionStrategy.ExecuteAsync((Func<Task<int>>)null, CancellationToken.None).Wait()).ParamName);
}
示例2: OperationCanceledException_thrown_if_task_is_cancelled
public void OperationCanceledException_thrown_if_task_is_cancelled()
{
var dynamicUpdateCommand = new Mock<DynamicUpdateCommand>(
new Mock<TableChangeProcessor>().Object,
new Mock<UpdateTranslator>().Object,
ModificationOperator.Delete,
/* originalValues */ null,
/* currentValues */ null,
new Mock<DbModificationCommandTree>().Object,
/*outputIdentifiers*/ null)
{
CallBase = true
}.Object;
Assert.Throws<OperationCanceledException>(
() => dynamicUpdateCommand.ExecuteAsync(null, null, new CancellationToken(canceled: true))
.GetAwaiter().GetResult());
}
示例3: Non_generic_ObjectQuery_ExecuteAsync_throws_OperationCanceledException_if_task_is_cancelled
public void Non_generic_ObjectQuery_ExecuteAsync_throws_OperationCanceledException_if_task_is_cancelled()
{
var objectQuery = new Mock<ObjectQuery>{ CallBase = true }.Object;
Assert.Throws<OperationCanceledException>(
() => objectQuery.ExecuteAsync(0, new CancellationToken(canceled: true))
.GetAwaiter().GetResult());
}
示例4: OperationCanceledException_thrown_if_task_is_cancelled
public void OperationCanceledException_thrown_if_task_is_cancelled()
{
var mockTranslator = new Mock<UpdateTranslator>();
mockTranslator.Setup(t => t.InterceptionContext).Returns(new DbInterceptionContext());
var stateEntry = new ExtractedStateEntry((EntityState)(-1), null, null, null);
var functionUpdateCommand =
new Mock<FunctionUpdateCommand>(mockTranslator.Object, new List<IEntityStateEntry>().AsReadOnly(),
stateEntry, new Mock<DbCommand>().Object)
{
CallBase = true
}.Object;
Assert.Throws<OperationCanceledException>(
() => functionUpdateCommand.ExecuteAsync(null, null, new CancellationToken(canceled: true))
.GetAwaiter().GetResult());
}
示例5: ExecuteAsync_Action_throws_on_null_parameters
public void ExecuteAsync_Action_throws_on_null_parameters()
{
var mockExecutionStrategy =
new Mock<ExecutionStrategyBase>
{
CallBase = true
}.Object;
Assert.Equal(
"func",
Assert.Throws<ArgumentNullException>(() => mockExecutionStrategy.ExecuteAsync(null, CancellationToken.None).Wait())
.ParamName);
}