public async Task StartAsync_TaskHubStarts() { // arrange Mock <IOrchestrationService> orchestrationMock = GetOrchestrationService(); var taskHubWorker = new TaskHubWorker(orchestrationMock.Object); var service = new TaskHubBackgroundService(taskHubWorker, s_logger, s_options); // act await service.StartAsync(CancellationToken.None); // assert orchestrationMock.Verify(x => x.StartAsync(), Times.Once); }
public async Task StopAsync_Cancelled() { // arrange Mock <IOrchestrationService> orchestrationMock = GetOrchestrationService(); var cancellation = new CancellationTokenSource(); orchestrationMock.Setup(x => x.StopAsync(false)) .Callback(() => cancellation.Cancel()) .Returns(Task.Delay(Timeout.Infinite)); var taskHubWorker = new TaskHubWorker(orchestrationMock.Object); var service = new TaskHubBackgroundService(taskHubWorker, s_logger, s_options); // act await service.StartAsync(CancellationToken.None); await service.StopAsync(cancellation.Token); // assert orchestrationMock.Verify(x => x.StopAsync(false), Times.Once); }