public static VsTsTool SetUpRealVsTsTool(Logger logger = null, PerformanceConfiguration pc = null) { var pat = AuthenticationHelper.GetPersonalAccessToken(); var vsTsTool = new VsTsTool(pat, logger: logger, performanceConfiguration: pc ?? SetUpPerformanceConfiguration()); return(vsTsTool); }
/// <inheritdoc /> public void ChangeItemContent(SourceInformation sourceInformation, TfvcItem existingItem, string content) { Validators.AssertIsNotNull(sourceInformation, nameof(sourceInformation)); Validators.AssertIsNotNull(existingItem, nameof(existingItem)); Validators.AssertIsNotNullOrEmpty(content, nameof(content)); Logger.Trace("Entering"); sourceInformation.AssertIsValid(); sourceInformation.AssertIsSourceType(SourceType.TfsVc); var isAdd = existingItem == null; var item = new TfvcItem { Path = sourceInformation.SourcePath, ContentMetadata = new FileContentMetadata { Encoding = 65001 } }; if (!isAdd) { item.ChangesetVersion = existingItem.ChangesetVersion; } var change = new TfvcChange { ChangeType = isAdd ? VersionControlChangeType.Add : VersionControlChangeType.Edit, NewContent = new ItemContent { Content = Convert.ToBase64String(Encoding.UTF8.GetBytes(content)), ContentType = ItemContentType.Base64Encoded }, Item = item }; var changeset = new TfvcChangeset { Comment = "Automatically " + (isAdd ? "Added" : "Updated") + " from API", Changes = new List <TfvcChange> { change } //PolicyOverride = new TfvcPolicyOverrideInfo("API", null), }; // submit the changeset var result = _client.Value.CreateChangesetAsync( changeset, VsTsTool.GetProjectNameFromPath(sourceInformation.SourcePath)) .Result; Console.WriteLine($"Changeset created for Add/Update. Id: {result.ChangesetId}."); }
public static void DoHttpClientRequest_Throws() { var vsTsTool = new VsTsTool("JunkPat"); Assert.That(() => vsTsTool.DoHttpClientRequest(null).Result, Throws.TypeOf <AggregateException>()); }
private static PolicyTool SetUpIntegration() { var pat = AuthenticationHelper.GetPersonalAccessToken(); var vsTsTool = new VsTsTool(pat); return(new PolicyTool(vsTsTool)); }
private void SetUpIntegration() { var pat = AuthenticationHelper.GetPersonalAccessToken(); _vsTsTool = new VsTsTool(pat); _releaseTool = new ReleaseTool(_vsTsTool); }
public static void Constructor_Succeeds() { const string org = "MyOrganization"; var result = new VsTsTool("accessToken", org, "projectName"); Assert.That(result.AzureDevOpsApiUri.ToString(), Is.EqualTo($"https://dev.azure.com/{org}")); }
/// <inheritdoc /> /// <summary> /// Constructor /// </summary> /// <param name="vsTsTool"></param> /// <param name="logger">Optional NLog Logger</param> /// <param name="performanceConfiguration">Optional Performance Configuration</param> public VcSourceTool(VsTsTool vsTsTool, Logger logger = null, PerformanceConfiguration performanceConfiguration = null) : base(logger, performanceConfiguration) { Validators.AssertIsNotNull(vsTsTool, nameof(vsTsTool)); Logger.Trace("Entering"); _client = vsTsTool.TfVcClient; }
private static VcSourceTool SetUpFake() { var vsTsTool = new VsTsTool( TestData.TokenFake, TestData.OrganizationFake, TestData.ProjectFake); return(new VcSourceTool(vsTsTool)); }
private static GitSourceTool SetUpClient() { var personalAccessToken = AuthenticationHelper.GetPersonalAccessToken(); var tool = new VsTsTool(AppSettings.ServerUri, personalAccessToken, AppSettings.Project); var client = new GitSourceTool(tool); return(client); }
public static void DoHttpClientRequest_TriesToAccessWeb() { var pat = AuthenticationHelper.GetPersonalAccessToken(); var vsTsTool = new VsTsTool(pat); var result = vsTsTool.DoHttpClientRequest("git/repositories").Result; Assert.That(result, Is.Not.Null); }
public static void GetProjectName_Throws_WithBadInput(string input) { var result = Assert.Throws <ArgumentException>(() => VsTsTool.GetProjectNameFromPath(input)); StringAssert.Contains( string.IsNullOrWhiteSpace(input) ? "null or whitespace" : "invalid TFS VC path", result.Message); }
public static VsTsTool SetUpFakeVsTsTool(PerformanceConfiguration pc = null, Logger logger = null) { var vsTsTool = new VsTsTool( TestData.TokenFake, TestData.OrganizationFake, TestData.ProjectFake, logger, pc ?? SetUpPerformanceConfiguration()); return(vsTsTool); }
public static void GetProjects() { var pat = AuthenticationHelper.GetPersonalAccessToken(); var vsTsTool = new VsTsTool(pat); var result = vsTsTool.GetProjects(); Assert.That(result, Is.Not.Null); Assert.That(result.Count(), Is.GreaterThan(0)); var myHandlers = new VariableDumpHandlers(); Console.WriteLine(result.DumpValues(0, handlers: myHandlers)); }
public static BuildTool SetUpRealBuildTool(out VsTsTool vsTsTool, PerformanceConfiguration pc = null) { if (pc == null) { pc = SetUpPerformanceConfiguration(); } var pat = AuthenticationHelper.GetPersonalAccessToken(); vsTsTool = new VsTsTool(pat, performanceConfiguration: pc); var output = new BuildTool(vsTsTool, performanceConfiguration: pc); return(output); }
/// <inheritdoc /> /// <summary> /// Constructor /// </summary> /// <param name="vsTsTool"></param> /// <param name="logger">Optional NLog Logger</param> /// <param name="performanceConfiguration">Optional Performance Configuration</param> public GitSourceTool( VsTsTool vsTsTool, Logger logger = null, PerformanceConfiguration performanceConfiguration = null) : base(logger, performanceConfiguration) { Validators.AssertIsNotNull(vsTsTool, nameof(vsTsTool)); Logger.Trace("Entering"); _vsTsTool = vsTsTool; _client = _vsTsTool.GitHttpClient; _repositoryIdCache = new ConcurrentDictionary <string, Guid>(); Logger.Trace("Exiting"); }
private ISourceTool <T> GetSourceTool() { ISourceTool <T> output = null; VsTsTool vsTsTool = null; if (_overrideSourceTool != null) { output = _overrideSourceTool; } else { if (_sourceType == SourceType.TfsVc || _sourceType == SourceType.TfsGit) { vsTsTool = new VsTsTool( _personalAccessToken, _organization, _projectName, _logger, _performanceConfiguration); } switch (_sourceType) { case SourceType.None: break; case SourceType.TfsVc: output = (ISourceTool <T>) new VcSourceTool(vsTsTool, _logger, _performanceConfiguration); break; case SourceType.TfsGit: output = (ISourceTool <T>) new GitSourceTool(vsTsTool, _logger, _performanceConfiguration); break; case SourceType.Filesystem: output = (ISourceTool <T>) new FilesystemSourceTool(_logger, _performanceConfiguration); break; default: throw new ArgumentOutOfRangeException(); } } return(output); }
/// <inheritdoc /> public void DeleteItem(SourceInformation sourceInformation, TfvcItem existingItem) { Validators.AssertIsNotNull(sourceInformation, nameof(sourceInformation)); Validators.AssertIsNotNull(existingItem, nameof(existingItem)); sourceInformation.AssertIsValid(); sourceInformation.AssertIsSourceType(SourceType.TfsVc); Logger.Trace("Entering"); var item = new TfvcItem { Path = sourceInformation.SourcePath, ContentMetadata = new FileContentMetadata { Encoding = 65001 }, ChangesetVersion = existingItem.ChangesetVersion }; var change = new TfvcChange { ChangeType = VersionControlChangeType.Delete, Item = item }; var changeset = new TfvcChangeset { Comment = "Automatically deleted from API", Changes = new List <TfvcChange> { change } //PolicyOverride = new TfvcPolicyOverrideInfo("API", null), }; // submit the changeset var result = _client.Value.CreateChangesetAsync( changeset, VsTsTool.GetProjectNameFromPath(sourceInformation.SourcePath)) .Result; Console.WriteLine($"Changeset created for delete. Id: {result.ChangesetId}."); }
public static void GetProjectName_Succeeds(string input, string expectedOutput) { var result = VsTsTool.GetProjectNameFromPath(input); Assert.That(result, Is.EqualTo(expectedOutput)); }