当前位置: 首页>>代码示例>>C#>>正文


C# Mock.ExecuteAsync方法代码示例

本文整理汇总了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);
            }
开发者ID:aspnet,项目名称:EntityFramework6,代码行数:13,代码来源:DbExecutionStrategyTests.cs

示例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());
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:18,代码来源:DynamicUpdateCommandTests.cs

示例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());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:8,代码来源:ObjectQueryTests.cs

示例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());
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:18,代码来源:FunctionUpdateCommandTests.cs

示例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);
            }
开发者ID:christiandpena,项目名称:entityframework,代码行数:13,代码来源:ExecutionStrategyBaseTests.cs


注:本文中的Mock.ExecuteAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。