public async Task Execute(TestContext context) { try { context.Service.Start(); foreach (var preconditionTask in _preconditions) { await preconditionTask(); } } catch (Exception e) { // Defined preconditions to execute test were not met. // Success? Test was not run. Failure? Test was not run. // Failure to run test for sure, but failure of test itself? Assert.Inconclusive("Test precondition criteria not met", e.Message, e); } var suspendedTask = WaitForState.Observe(context.Service, PlayerState.Idle, context.Token, context.Timeout); context.Service.Suspend(); await suspendedTask; }
public Task Execute(TestContext context) { var service = context.Service; service.Pause(); // Upon state subscription, current state will be replayed to subscriber. // When pausing already paused service, pause state will be replayed. return(WaitForState.Observe(service, PlayerState.Paused, context.Token, context.Timeout)); }
public Task Execute(TestContext context) { var service = context.Service; service.Start(); // State subscription will replay current state. If playing, // before calling start(), playerStateTask shall be completed. return(WaitForState.Observe(service, PlayerState.Playing, context.Token, context.Timeout)); }
public Task Execute(TestContext context) { var stateTask = WaitForState.Observe(context.Service, PlayerState.Playing, context.Token, context.Timeout); var clockTask = RunningClockTask.Observe(context.Service, context.Token, context.Timeout); var resumeTask = context.Service.Resume().WithTimeout(context.Timeout).WithCancellation(context.Token); // Jolly resume operation is when: // - Resume() completes. // - Playing state is observed. // - Running clock is observed. return(Task.WhenAll(resumeTask, stateTask, clockTask)); }
public Task Execute(TestContext context) { var service = context.Service; var clipTitle = context.ClipTitle; var clips = service.ReadClips(); var clip = clips.Find(_ => _.Title.Equals(clipTitle)); Assert.That(clip, Is.Not.Null); var playerStateTask = WaitForState.Observe(service, PlayerState.Prepared, context.Token, context.Timeout); service.SetSource(clip); return(playerStateTask); }
public async Task VerifyRunning(TimeSpan duration) { // Playing state first. await WaitForState.Observe(_service, PlayerState.Playing, _context.Token, _context.Timeout); // Start clock & termination listners. var runningClockTask = RunningClockTask.Observe(_service, _context.Token, _context.Timeout); await Task.WhenAny(_playbackErrorTask, _clipCompletedTask, Task.Delay(duration)).WithCancellation(_context.Token); if (_playbackErrorTask.IsCompleted || _clipCompletedTask.IsCompleted) { throw new Exception($"Playback terminated or not running. " + $"Error: {_playbackErrorTask.IsCompleted} " + $"Completed: {_clipCompletedTask.IsCompleted}"); } // verify running clock await runningClockTask; }