public async Task <SettingsContainer> CaptureSettings(FileSettings settingsIn, bool addCommandRepoInclude = false, bool addCommandRepoExclude = false) { var logger = Substitute.For <IConfigureLogLevel>(); var fileSettings = Substitute.For <IFileSettingsCache>(); SettingsContainer settingsOut = null; var engine = Substitute.For <IGitHubEngine>(); await engine.Run(Arg.Do <SettingsContainer>(x => settingsOut = x)); fileSettings.Get().Returns(settingsIn); var command = new OrganisationCommand(engine, logger, fileSettings); command.GitHubToken = "testToken"; command.GithubOrganisationName = "testOrg"; if (addCommandRepoInclude) { command.IncludeRepos = "IncludeFromCommand"; } if (addCommandRepoExclude) { command.ExcludeRepos = "ExcludeFromCommand"; } await command.OnExecute(); return(settingsOut); }
public async Task ShouldCallEngineAndNotSucceedWithoutParams() { var engine = Substitute.For <IGitHubEngine>(); var logger = Substitute.For <IConfigureLogger>(); var fileSettings = Substitute.For <IFileSettingsCache>(); fileSettings.GetSettings().Returns(FileSettings.Empty()); var command = new OrganisationCommand(engine, logger, fileSettings); var status = await command.OnExecute(); Assert.That(status, Is.EqualTo(-1)); await engine .DidNotReceive() .Run(Arg.Any <SettingsContainer>()); }
public static async Task <(SettingsContainer fileSettings, CollaborationPlatformSettings platformSettings)> CaptureSettings( FileSettings settingsIn, bool addCommandRepoInclude = false, bool addCommandRepoExclude = false, int?maxRepo = null, ForkMode?forkMode = null) { var logger = Substitute.For <IConfigureLogger>(); var fileSettings = Substitute.For <IFileSettingsCache>(); SettingsContainer settingsOut = null; var engine = Substitute.For <ICollaborationEngine>(); await engine.Run(Arg.Do <SettingsContainer>(x => settingsOut = x)); fileSettings.GetSettings().Returns(settingsIn); var collaborationFactory = GetCollaborationFactory(); var command = new OrganisationCommand(engine, logger, fileSettings, collaborationFactory); command.PersonalAccessToken = "testToken"; command.GithubOrganisationName = "testOrg"; if (addCommandRepoInclude) { command.IncludeRepos = "IncludeFromCommand"; } if (addCommandRepoExclude) { command.ExcludeRepos = "ExcludeFromCommand"; } if (forkMode != null) { command.ForkMode = forkMode; } command.MaxRepositoriesChanged = maxRepo; await command.OnExecute(); return(settingsOut, collaborationFactory.Settings); }
public async Task ShouldCallEngineAndSucceedWithRequiredGithubParams() { var engine = Substitute.For <IGitHubEngine>(); var logger = Substitute.For <IConfigureLogger>(); var fileSettings = Substitute.For <IFileSettingsCache>(); fileSettings.GetSettings().Returns(FileSettings.Empty()); var command = new OrganisationCommand(engine, logger, fileSettings); command.GitHubToken = "abc"; command.GithubOrganisationName = "testOrg"; var status = await command.OnExecute(); Assert.That(status, Is.EqualTo(0)); await engine .Received(1) .Run(Arg.Any <SettingsContainer>()); }
public async Task ShouldCallEngineAndSucceedWithRequiredAzureDevOpsParams() { var engine = Substitute.For <ICollaborationEngine>(); var logger = Substitute.For <IConfigureLogger>(); var fileSettings = Substitute.For <IFileSettingsCache>(); fileSettings.GetSettings().Returns(FileSettings.Empty()); var collaborationFactory = GetCollaborationFactory((d, e) => new AzureDevOpsSettingsReader(d, e)); var command = new OrganisationCommand(engine, logger, fileSettings, collaborationFactory); command.PersonalAccessToken = "abc"; command.OrganisationName = "testOrg"; command.ApiEndpoint = "https://dev.azure.com/org"; var status = await command.OnExecute(); Assert.That(status, Is.EqualTo(0)); await engine .Received(1) .Run(Arg.Any <SettingsContainer>()); }