public async Task Will_install_dependencies_for_all_projects_by_default() { _configServiceMock.Setup(m => m.GetConfigurationAsync(It.IsAny <CommandOptions>())) .ReturnsAsync(SampleProjects.ConfigurationDefault) .Verifiable(); _runnerServiceMock.Setup(m => m.InstallAsync(It.IsAny <IList <Project> >(), It.IsAny <CommandOptions>(), It.IsAny <CancellationToken>())) .Callback((IList <Project> projects, CommandOptions options, CancellationToken token) => { foreach (var p in projects) { p.Processes.Add(new AppProcess(new Process(), AppTask.Install, AppStatus.Success)); } }) .Returns((IList <Project> projects, CommandOptions options, CancellationToken token) => Task.FromResult(projects)) .Verifiable(); InstallCommand command = CreateCommand(); int statusCode = await command.OnExecute(); Assert.Equal(0, statusCode); _configServiceMock.Verify(); _runnerServiceMock.Verify(); }
public async Task Returns_fail_count_as_exit_code() { _configServiceMock.Setup(m => m.GetConfigurationAsync(It.IsAny <CommandOptions>())) .ReturnsAsync(SampleProjects.ConfigurationDefault) .Verifiable(); _runnerServiceMock.Setup(m => m.InstallAsync(It.IsAny <IList <Project> >(), It.IsAny <CommandOptions>(), It.IsAny <CancellationToken>())) .Callback((IList <Project> projects, CommandOptions options, CancellationToken token) => { projects[0].Processes.Add(new AppProcess(new Process(), AppTask.Install, AppStatus.Failure)); }) .Returns((IList <Project> projects, CommandOptions options, CancellationToken token) => Task.FromResult(projects)) .Verifiable(); InstallCommand command = CreateCommand(); int testProjectCount = await command.OnExecute(); Assert.Equal(1, testProjectCount); _configServiceMock.Verify(); _runnerServiceMock.Verify(); }