public void execute_async_throws_if_context_is_null()
        {
            var sut = new SayActionBuilder()
                .Build();

            Assert.Throws<ArgumentNullException>(() => sut.ExecuteAsync(null));
        }
        public void execute_async_throws_if_context_is_null()
        {
            var sut = new SayActionBuilder()
                      .Build();

            Assert.Throws <ArgumentNullException>(() => sut.ExecuteAsync(null));
        }
        public void execute_async_cancels_if_context_is_cancelled()
        {
            var sut = new SayActionBuilder()
                .Build();

            using (var context = new ExecutionContext())
            {
                context.Cancel();

                Assert.Throws<OperationCanceledException>(() => sut.ExecuteAsync(context));
            }
        }
        public void execute_async_cancels_if_context_is_cancelled()
        {
            var sut = new SayActionBuilder()
                      .Build();

            using (var context = new ExecutionContext())
            {
                context.Cancel();

                Assert.Throws <OperationCanceledException>(() => sut.ExecuteAsync(context));
            }
        }
        public void execute_async_passes_the_speech_text_onto_the_speech_service(string speechText)
        {
            var speechService = new SpeechServiceMock(MockBehavior.Loose);
            var sut           = new SayActionBuilder()
                                .WithSpeechService(speechService)
                                .WithSpeechText(speechText)
                                .Build();

            sut.ExecuteAsync(new ExecutionContext());

            speechService
            .Verify(x => x.SpeakAsync(speechText, It.IsAny <CancellationToken>()))
            .WasCalledExactlyOnce();
        }
        public void execute_async_pauses_if_context_is_paused()
        {
            var speechService = new SpeechServiceMock(MockBehavior.Loose);
            var sut = new SayActionBuilder()
                .WithSpeechService(speechService)
                .Build();

            using (var context = new ExecutionContext())
            {
                context.IsPaused = true;

                sut.ExecuteAsync(context);

                speechService
                    .Verify(x => x.SpeakAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()))
                    .WasNotCalled();
            }
        }
        public void execute_async_pauses_if_context_is_paused()
        {
            var speechService = new SpeechServiceMock(MockBehavior.Loose);
            var sut           = new SayActionBuilder()
                                .WithSpeechService(speechService)
                                .Build();

            using (var context = new ExecutionContext())
            {
                context.IsPaused = true;

                sut.ExecuteAsync(context);

                speechService
                .Verify(x => x.SpeakAsync(It.IsAny <string>(), It.IsAny <CancellationToken>()))
                .WasNotCalled();
            }
        }
        public void execute_async_passes_the_speech_text_onto_the_speech_service(string speechText)
        {
            var speechService = new SpeechServiceMock(MockBehavior.Loose);
            var sut = new SayActionBuilder()
                .WithSpeechService(speechService)
                .WithSpeechText(speechText)
                .Build();

            sut.ExecuteAsync(new ExecutionContext());

            speechService
                .Verify(x => x.SpeakAsync(speechText, It.IsAny<CancellationToken>()))
                .WasCalledExactlyOnce();
        }