private void RunPlayerTest(string clipTitle, Func <TestContext, Task> testImpl) { AsyncContext.Run(async() => { _logger.Info($"Begin: {NUnit.Framework.TestContext.CurrentContext.Test.FullName}"); using (var cts = new CancellationTokenSource()) { using (var service = new PlayerService()) { try { var context = new TestContext { Service = service, ClipTitle = clipTitle, Token = cts.Token, // Requested seek position may differ from // seek position issued to player. Difference can be 10s+ // Encrypted streams (Widevine in particular) may have LONG license // installation times (10s+). // DRM content has larger timeout Timeout = TSPlayerServiceTestCaseSource.IsEncrypted(clipTitle) ? TimeSpan.FromSeconds(40) : TimeSpan.FromSeconds(20) }; var prepareOperation = new PrepareOperation(); prepareOperation.Prepare(context); await prepareOperation.Execute(context); var startOperation = new StartOperation(); startOperation.Prepare(context); await startOperation.Execute(context); await testImpl(context); } catch (Exception e) { _logger.Error($"Error: {NUnit.Framework.TestContext.CurrentContext.Test.FullName} {e.Message} {e.StackTrace}"); throw; } // Test completed. Cancel token to kill any test's sub activities. // Do so before PlayerService gets destroyed (in case those activities access it) cts.Cancel(); } } _logger.Info($"End: {NUnit.Framework.TestContext.CurrentContext.Test.FullName}"); }); }
private void RunPlayerTest(string clipTitle, Func <TestContext, Task> testImpl) { AsyncContext.Run(async() => { using (var service = new PlayerService()) using (var cts = new CancellationTokenSource()) { var context = new TestContext { Service = service, ClipTitle = clipTitle, Token = cts.Token, Timeout = TimeSpan.FromSeconds(20) }; await new PrepareOperation().Execute(context); await new StartOperation().Execute(context); await testImpl(context); } }); }
private async Task CompletePendingOperations(TestContext context, IEnumerable <(Task task, Type operationType, DateTimeOffset when)> operations)
public void Prepare(TestContext context) { }