public async Task RestartUnfinishedBuild() { using (var env = new EngineServiceTestEnvironment()) { env.CreateEngineService(); Engine engine = await env.CreateEngineAsync(); EngineRuntime runtime = env.GetRuntime(engine.Id); await runtime.InitNewAsync(); env.BatchTrainer.Train(Arg.Any <IProgress <ProgressStatus> >(), Arg.Do <Action>(checkCanceled => { while (true) { checkCanceled(); } })); Build build = await runtime.StartBuildAsync(); Assert.That(build, Is.Not.Null); await env.WaitForBuildToStartAsync(build.Id); env.DisposeEngineService(); build = await env.BuildRepository.GetAsync(build.Id); Assert.That(build.State, Is.EqualTo(BuildStates.Pending)); env.CreateEngineService(); await env.WaitForBuildToFinishAsync(build.Id); build = await env.BuildRepository.GetAsync(build.Id); Assert.That(build.State, Is.EqualTo(BuildStates.Completed)); } }
public async Task StartBuildAsync_BatchTrainerCalled() { using (var env = new EngineServiceTestEnvironment()) { env.CreateEngineService(); Engine engine = await env.CreateEngineAsync(); EngineRuntime runtime = env.GetRuntime(engine.Id); await runtime.InitNewAsync(); Build build = await runtime.StartBuildAsync(); Assert.That(build, Is.Not.Null); await env.WaitForBuildToFinishAsync(build.Id); env.BatchTrainer.Received().Train(Arg.Any <IProgress <ProgressStatus> >(), Arg.Any <Action>()); env.BatchTrainer.Received().Save(); build = await env.BuildRepository.GetAsync(build.Id); Assert.That(build.State, Is.EqualTo(BuildStates.Completed)); } }