Example #1
0
        internal async Task PerformOperationExecuteTestAsSubordinateWithCallback(OperationBase operation, CallbackMessage cbMessage, bool cancelAndCheckStateOnExit = true)
        {
            _manualResetEvent.Reset();
            _callbackMessageUponRequest = cbMessage;
            HookOperationEvent(operation);
            var connOp = await PerformOperationExecuteTestAsPrimary(new ConnectionOperation(), false);

            await connOp.AddAndExecuteSubordinate(operation);

            operation.State.Should().Be(OperationState.Executing);
            if (await WaitForCallback())
            {
                GetComparisonValuesFromMessage(cbMessage).Equals(CallbackValues).Should().Be(true);
            }
            else
            {
                throw new Exception("Timeout waiting for callback message");
            }
            ThrowIfConnectorClosed();
            if (cancelAndCheckStateOnExit)
            {
                await operation.CancelAsync();

                operation.State.Should().Be(OperationState.Canceled);
                await connOp.CancelAsync();

                connOp.State.Should().Be(OperationState.Canceled);
            }
        }
Example #2
0
        internal async Task PerformOperationExecuteTestAsSubordinate(OperationBase operation, bool cancelAndCheckStateOnExit = true)
        {
            var connOp = await PerformOperationExecuteTestAsPrimary(new ConnectionOperation(), false);

            await connOp.AddAndExecuteSubordinate(operation);

            operation.State.Should().Be(OperationState.Executing);
            ThrowIfConnectorClosed();
            if (cancelAndCheckStateOnExit)
            {
                await operation.CancelAsync();

                operation.State.Should().Be(OperationState.Canceled);
                await connOp.CancelAsync();

                connOp.State.Should().Be(OperationState.Canceled);
            }
        }