public Task <IIssueResultWithPostAction> FileIssueAsync(IssueInformation issueInfo) { bool topMost = false; Application.Current.Dispatcher.Invoke(() => topMost = Application.Current.MainWindow.Topmost); Action <int> updateZoom = (int x) => Configuration.ZoomLevel = x; (int?issueId, string newIssueId) = _fileIssueHelpers.FileNewIssue(issueInfo, Configuration.SavedConnection, topMost, Configuration.ZoomLevel, updateZoom, this.ConfigurationPath); return(Task.Run <IIssueResultWithPostAction>(() => { // Check whether issue was filed once dialog closed & process accordingly if (!issueId.HasValue) { return null; } try { if (!_fileIssueHelpers.AttachIssueData(issueInfo, newIssueId, issueId.Value).Result) { return new IssueResultWithPostAction() { DisplayText = null, IssueLink = null, PostAction = () => { MessageDialog.Show(Properties.Resources.There_was_an_error_identifying_the_created_issue_This_may_occur_if_the_ID_used_to_create_the_issue_is_removed_from_its_Azure_DevOps_description_Attachments_have_not_been_uploaded); }, }; } return new IssueResultWithPostAction() { DisplayText = issueId.ToString(), IssueLink = _devOpsIntegration.GetExistingIssueUrl(issueId.Value), PostAction = null, }; } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception e) { e.ReportException(); } #pragma warning restore CA1031 // Do not catch general exception types return null; })); }
public void FileNewIssue_IsNotEnabled_ReturnsPlaceholder() { using (ShimsContext.Create()) { ShimAzureDevOpsIntegration.AllInstances.ConnectedToAzureDevOpsGet = (_) => false; var issueInfo = new IssueInformation(); var connInfo = new ConnectionInfo(); var output = FileIssueHelpers.FileNewIssue(issueInfo, connInfo, false, 0, (_) => { }); Assert.IsNull(output.issueId); Assert.IsNotNull(output.newIssueId); Assert.IsTrue(string.IsNullOrEmpty(output.newIssueId)); } }
public Task <IIssueResult> FileIssueAsync(IssueInformation issueInfo) { bool topMost = false; Application.Current.Dispatcher.Invoke(() => topMost = Application.Current.MainWindow.Topmost); Action <int> updateZoom = (int x) => Configuration.ZoomLevel = x; (int?issueId, string newIssueId) = FileIssueHelpers.FileNewIssue(issueInfo, Configuration.SavedConnection, topMost, Configuration.ZoomLevel, updateZoom); return(Task.Run <IIssueResult>(() => { // Check whether issue was filed once dialog closed & process accordingly if (!issueId.HasValue) { return null; } try { if (!FileIssueHelpers.AttachIssueData(issueInfo, newIssueId, issueId.Value).Result) { MessageDialog.Show(Properties.Resources.There_was_an_error_identifying_the_created_issue_This_may_occur_if_the_ID_used_to_create_the_issue_is_removed_from_its_Azure_DevOps_description_Attachments_have_not_been_uploaded); } return new IssueResult() { DisplayText = issueId.ToString(), IssueLink = AzureDevOps.GetExistingIssueUrl(issueId.Value) }; } catch (Exception) { } return null; })); }
public void FileNewIssue_FileIssueIsNull_ThrowsArgumentNullException() { _fileIssueHelpers.FileNewIssue(null, new ConnectionInfo(), false, 100, (unused) => { Assert.Fail("This method should never be called"); }); }