Exemplo n.º 1
0
        public void execute_async_throws_if_context_is_null()
        {
            var sut = new AudioActionBuilder()
                      .Build();

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

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

                Assert.Throws<OperationCanceledException>(() => sut.ExecuteAsync(context));
            }
        }
Exemplo n.º 3
0
        public void execute_async_cancels_if_context_is_cancelled()
        {
            var sut = new AudioActionBuilder()
                      .Build();

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

                Assert.Throws <OperationCanceledException>(() => sut.ExecuteAsync(context));
            }
        }
Exemplo n.º 4
0
        public void execute_async_passes_the_audio_name_onto_the_audio_service(string audioName)
        {
            var audioService = new AudioServiceMock(MockBehavior.Loose);
            var sut          = new AudioActionBuilder()
                               .WithAudioService(audioService)
                               .WithAudioName(audioName)
                               .Build();

            sut.ExecuteAsync(new ExecutionContext());

            audioService
            .Verify(x => x.PlayAsync(audioName))
            .WasCalledExactlyOnce();
        }
        public void execute_async_pauses_if_context_is_paused()
        {
            var audioService = new AudioServiceMock(MockBehavior.Loose);
            var sut = new AudioActionBuilder()
                .WithAudioService(audioService)
                .Build();

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

                sut.ExecuteAsync(context);

                audioService
                    .Verify(x => x.PlayAsync(It.IsAny<string>()))
                    .WasNotCalled();
            }
        }
Exemplo n.º 6
0
        public void execute_async_pauses_if_context_is_paused()
        {
            var audioService = new AudioServiceMock(MockBehavior.Loose);
            var sut          = new AudioActionBuilder()
                               .WithAudioService(audioService)
                               .Build();

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

                sut.ExecuteAsync(context);

                audioService
                .Verify(x => x.PlayAsync(It.IsAny <string>()))
                .WasNotCalled();
            }
        }
        public void execute_async_passes_the_audio_name_onto_the_audio_service(string audioName)
        {
            var audioService = new AudioServiceMock(MockBehavior.Loose);
            var sut = new AudioActionBuilder()
                .WithAudioService(audioService)
                .WithAudioName(audioName)
                .Build();

            sut.ExecuteAsync(new ExecutionContext());

            audioService
                .Verify(x => x.PlayAsync(audioName))
                .WasCalledExactlyOnce();
        }
 public void execute_async_throws_if_context_is_null()
 {
     var sut = new AudioActionBuilder()
         .Build();
     Assert.Throws<ArgumentNullException>(() => sut.ExecuteAsync(null));
 }