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());
        }
Exemplo n.º 2
0
            public void Exception_thrown_if_CommandBehavior_is_not_SequentialAccess()
            {
                var entityCommandDefinition = new Mock <EntityCommandDefinition>(null, null, null)
                {
                    CallBase = true
                }.Object;

                AssertThrowsInAsyncMethod <InvalidOperationException>(
                    Strings.ADP_MustUseSequentialAccess,
                    () =>
                    entityCommandDefinition.ExecuteAsync(default(EntityCommand), CommandBehavior.Default, CancellationToken.None).Wait());
            }
            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);
            }
            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);
            }
            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());
            }
Exemplo n.º 6
0
            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());
            }
            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);
            }
            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());
            }
            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());
            }
Exemplo n.º 10
0
        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());
        }
            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);
            }