From 2d80c5cf899c5eb05f8e92f5ea8d29c09e832449 Mon Sep 17 00:00:00 2001 From: Alexander Hjelm Date: Sat, 14 Oct 2023 05:51:45 +0200 Subject: [PATCH] Code cleanup --- .../JiraExport/IJiraProvider.cs | 6 ++--- .../JiraExport/JiraCommandLine.cs | 15 +++++------- src/WorkItemMigrator/JiraExport/JiraItem.cs | 17 +++++++------ src/WorkItemMigrator/JiraExport/JiraMapper.cs | 13 +++++----- .../JiraExport/JiraProvider.cs | 16 ++++++------- .../JiraExport/JiraRevision.cs | 4 ++-- src/WorkItemMigrator/JiraExport/Program.cs | 4 ++-- .../RevisionUtils/FieldMapperUtils.cs | 5 ++-- .../Migration.Common.Log/Logger.cs | 8 +++---- .../Migration.Common.Log/VersionInfo.cs | 6 ++--- .../Migration.Common/BaseMapper.cs | 4 ++-- .../Config/ConfigReaderJson.cs | 12 +++++----- .../Migration.Common/MigrationContext.cs | 8 +++---- .../Migration.Common/RevisionUtility.cs | 4 ++-- .../Migration.Common/UserMapper.cs | 5 ++-- .../Migration.WIContract/WiItemProvider.cs | 8 +++---- src/WorkItemMigrator/WorkItemImport/Agent.cs | 20 +++++++--------- .../WorkItemImport/ExecutionPlan.cs | 4 ++-- .../WorkItemImport/ExecutionPlanBuilder.cs | 6 ++--- .../WorkItemImport/ImportCommandLine.cs | 16 ++++++------- .../WorkItemImport/Program.cs | 4 ++-- .../WitClient/IWitClientWrapper.cs | 6 ++--- .../WitClient/WitClientUtils.cs | 17 +++++++------ .../WitClient/WitClientWrapper.cs | 10 ++++---- .../JsonExtensionsTests.cs | 5 ++-- .../MigrationCommonTests.cs | 9 ++++--- .../MigrationContextTests.cs | 7 +++--- .../RevisionUtilityTests.cs | 9 ++++--- .../JiraAttachmentTest.cs | 7 +++--- .../JiraChangeItemTests.cs | 7 +++--- .../JiraCommandLineTests.cs | 7 +++--- .../JiraItemTests.cs | 19 +++++++-------- .../JiraLinkTests.cs | 7 +++--- .../JiraMapperTests.cs | 21 ++++++++-------- .../JiraProviderTests.cs | 9 ++++--- .../JiraRevisionTests.cs | 7 +++--- .../RevisionUtils/FieldMapperUtilsTests.cs | 13 +++++----- .../RevisionUtils/LinkMapperUtilsTests.cs | 15 ++++++------ .../WiFieldTests.cs | 3 +-- .../Migration.WIContract.Tests/WiItemTests.cs | 3 +-- .../WiRevisionTests.cs | 3 +-- .../ImportCommandLineTests.cs | 7 +++--- .../WitClient/JsonPatchDocUtilsTests.cs | 12 ++++------ .../WitClient/WitClientUtilsTests.cs | 24 +++++++++---------- 44 files changed, 186 insertions(+), 226 deletions(-) diff --git a/src/WorkItemMigrator/JiraExport/IJiraProvider.cs b/src/WorkItemMigrator/JiraExport/IJiraProvider.cs index 01a5c2df..83696f7a 100644 --- a/src/WorkItemMigrator/JiraExport/IJiraProvider.cs +++ b/src/WorkItemMigrator/JiraExport/IJiraProvider.cs @@ -1,10 +1,10 @@ -using System; +using Atlassian.Jira; +using Newtonsoft.Json.Linq; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Atlassian.Jira; -using Newtonsoft.Json.Linq; using static JiraExport.JiraProvider; namespace JiraExport diff --git a/src/WorkItemMigrator/JiraExport/JiraCommandLine.cs b/src/WorkItemMigrator/JiraExport/JiraCommandLine.cs index 385e0aea..34b6fa27 100644 --- a/src/WorkItemMigrator/JiraExport/JiraCommandLine.cs +++ b/src/WorkItemMigrator/JiraExport/JiraCommandLine.cs @@ -1,16 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; - -using Common.Config; - +using Common.Config; using Microsoft.Extensions.CommandLineUtils; - using Migration.Common.Config; using Migration.Common.Log; using Migration.WIContract; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; using static JiraExport.JiraProvider; namespace JiraExport diff --git a/src/WorkItemMigrator/JiraExport/JiraItem.cs b/src/WorkItemMigrator/JiraExport/JiraItem.cs index 425c43c1..a64b3056 100644 --- a/src/WorkItemMigrator/JiraExport/JiraItem.cs +++ b/src/WorkItemMigrator/JiraExport/JiraItem.cs @@ -1,13 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; - -using Atlassian.Jira; +using Atlassian.Jira; using Migration.Common; using Migration.Common.Log; - using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; namespace JiraExport { @@ -37,7 +35,7 @@ private static List BuildRevisions(JiraItem jiraItem, IJiraProvide string issueKey = jiraItem.Key; var remoteIssue = jiraItem.RemoteIssue; Dictionary fieldsTemp = ExtractFields(issueKey, remoteIssue, jiraProvider); - + // Add CustomFieldName fields, copy over all non-custom fields. // These get removed as we loop over the changeLog, so we're left with the original Jira values by the time we reach firstRevision. Dictionary fields = new Dictionary(StringComparer.InvariantCultureIgnoreCase); @@ -47,7 +45,8 @@ private static List BuildRevisions(JiraItem jiraItem, IJiraProvide if (!String.IsNullOrEmpty(key)) { fields[key] = field.Value; - } else + } + else { fields[field.Key] = field.Value; } diff --git a/src/WorkItemMigrator/JiraExport/JiraMapper.cs b/src/WorkItemMigrator/JiraExport/JiraMapper.cs index 901d469f..edd73cbe 100644 --- a/src/WorkItemMigrator/JiraExport/JiraMapper.cs +++ b/src/WorkItemMigrator/JiraExport/JiraMapper.cs @@ -1,12 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Common.Config; - +using Common.Config; using Migration.Common; using Migration.Common.Config; using Migration.Common.Log; using Migration.WIContract; +using System; +using System.Collections.Generic; +using System.Linq; [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Migration.Jira-Export.Tests")] @@ -371,7 +370,7 @@ private HashSet InitializeTypeMappings() private Func IfChanged(string sourceField, bool isCustomField, Func mapperFunc = null) { // Store both the customFieldName and the sourceField as the changelog seems to only use the customFieldName, which is then passed into this function as the sourceField. - string customFieldName=""; + string customFieldName = ""; if (isCustomField) { customFieldName = _jiraProvider.GetCustomId(sourceField); @@ -391,7 +390,7 @@ private HashSet InitializeTypeMappings() { return (true, (T)value); } - } + } else if (r.Fields.TryGetValue(customFieldName.ToLower(), out value)) { if (mapperFunc != null) diff --git a/src/WorkItemMigrator/JiraExport/JiraProvider.cs b/src/WorkItemMigrator/JiraExport/JiraProvider.cs index 8dc85acc..c2e3813c 100644 --- a/src/WorkItemMigrator/JiraExport/JiraProvider.cs +++ b/src/WorkItemMigrator/JiraExport/JiraProvider.cs @@ -1,17 +1,15 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using System.Web; -using Atlassian.Jira; +using Atlassian.Jira; using Atlassian.Jira.Remote; using Migration.Common; using Migration.Common.Log; - using Newtonsoft.Json.Linq; - using RestSharp; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Web; namespace JiraExport { diff --git a/src/WorkItemMigrator/JiraExport/JiraRevision.cs b/src/WorkItemMigrator/JiraExport/JiraRevision.cs index f7aa35a1..e95201c2 100644 --- a/src/WorkItemMigrator/JiraExport/JiraRevision.cs +++ b/src/WorkItemMigrator/JiraExport/JiraRevision.cs @@ -1,7 +1,7 @@ -using System; +using Migration.Common; +using System; using System.Collections.Generic; using System.Linq; -using Migration.Common; namespace JiraExport { diff --git a/src/WorkItemMigrator/JiraExport/Program.cs b/src/WorkItemMigrator/JiraExport/Program.cs index a274785b..04609151 100644 --- a/src/WorkItemMigrator/JiraExport/Program.cs +++ b/src/WorkItemMigrator/JiraExport/Program.cs @@ -1,5 +1,5 @@ -using System; -using Migration.Common.Log; +using Migration.Common.Log; +using System; namespace JiraExport { diff --git a/src/WorkItemMigrator/JiraExport/RevisionUtils/FieldMapperUtils.cs b/src/WorkItemMigrator/JiraExport/RevisionUtils/FieldMapperUtils.cs index 4d0ddd5b..4de29ddb 100644 --- a/src/WorkItemMigrator/JiraExport/RevisionUtils/FieldMapperUtils.cs +++ b/src/WorkItemMigrator/JiraExport/RevisionUtils/FieldMapperUtils.cs @@ -20,12 +20,13 @@ public static object MapRemainingWork(string seconds) var secs = 0d; try { - if(seconds == null) + if (seconds == null) { throw new FormatException(); } secs = Convert.ToDouble(seconds); - } catch (FormatException) + } + catch (FormatException) { Logger.Log(LogLevel.Warning, $"A FormatException was thrown when converting RemainingWork value '{seconds}' to double. Defaulting to RemainingWork = null."); return null; diff --git a/src/WorkItemMigrator/Migration.Common.Log/Logger.cs b/src/WorkItemMigrator/Migration.Common.Log/Logger.cs index 8c37cf4e..438f20f4 100644 --- a/src/WorkItemMigrator/Migration.Common.Log/Logger.cs +++ b/src/WorkItemMigrator/Migration.Common.Log/Logger.cs @@ -1,10 +1,10 @@ -using System; +using Microsoft.ApplicationInsights; +using Microsoft.ApplicationInsights.DataContracts; +using Microsoft.ApplicationInsights.Extensibility; +using System; using System.Collections.Generic; using System.Configuration; using System.IO; -using Microsoft.ApplicationInsights; -using Microsoft.ApplicationInsights.DataContracts; -using Microsoft.ApplicationInsights.Extensibility; namespace Migration.Common.Log { diff --git a/src/WorkItemMigrator/Migration.Common.Log/VersionInfo.cs b/src/WorkItemMigrator/Migration.Common.Log/VersionInfo.cs index 33da85df..6288f04a 100644 --- a/src/WorkItemMigrator/Migration.Common.Log/VersionInfo.cs +++ b/src/WorkItemMigrator/Migration.Common.Log/VersionInfo.cs @@ -1,8 +1,8 @@ -using System; +using Newtonsoft.Json.Linq; +using Semver; +using System; using System.Diagnostics; using System.Net.Http; -using Newtonsoft.Json.Linq; -using Semver; namespace Migration.Common.Log { diff --git a/src/WorkItemMigrator/Migration.Common/BaseMapper.cs b/src/WorkItemMigrator/Migration.Common/BaseMapper.cs index 2c04ae41..39804493 100644 --- a/src/WorkItemMigrator/Migration.Common/BaseMapper.cs +++ b/src/WorkItemMigrator/Migration.Common/BaseMapper.cs @@ -1,6 +1,6 @@ -using System; +using Migration.Common.Log; +using System; using System.Collections.Generic; -using Migration.Common.Log; namespace Migration.Common { diff --git a/src/WorkItemMigrator/Migration.Common/Config/ConfigReaderJson.cs b/src/WorkItemMigrator/Migration.Common/Config/ConfigReaderJson.cs index c0dba56d..ad3a081f 100644 --- a/src/WorkItemMigrator/Migration.Common/Config/ConfigReaderJson.cs +++ b/src/WorkItemMigrator/Migration.Common/Config/ConfigReaderJson.cs @@ -1,11 +1,11 @@ -using System; +using Common.Config; +using Migration.Common.Log; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Common.Config; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Migration.Common.Log; namespace Migration.Common.Config { @@ -87,7 +87,7 @@ public ConfigJson DeserializeText(string input) } result.TypeMap.Types.AddRange(types); - if(obj.ContainsKey("repository-map")) + if (obj.ContainsKey("repository-map")) { var repositories = obj.SelectToken("repository-map.repository").Select(li => li.ToObject()).ToList(); if (result.RepositoryMap.Repositories == null) diff --git a/src/WorkItemMigrator/Migration.Common/MigrationContext.cs b/src/WorkItemMigrator/Migration.Common/MigrationContext.cs index 5a5945cd..f02606be 100644 --- a/src/WorkItemMigrator/Migration.Common/MigrationContext.cs +++ b/src/WorkItemMigrator/Migration.Common/MigrationContext.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Common.Config; +using Common.Config; using Migration.Common.Log; using Migration.WIContract; +using System.Collections.Generic; +using System.IO; +using System.Linq; namespace Migration.Common { diff --git a/src/WorkItemMigrator/Migration.Common/RevisionUtility.cs b/src/WorkItemMigrator/Migration.Common/RevisionUtility.cs index b92a37bb..c33272c7 100644 --- a/src/WorkItemMigrator/Migration.Common/RevisionUtility.cs +++ b/src/WorkItemMigrator/Migration.Common/RevisionUtility.cs @@ -1,8 +1,8 @@ -using System; +using Migration.WIContract; +using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; -using Migration.WIContract; namespace Migration.Common { diff --git a/src/WorkItemMigrator/Migration.Common/UserMapper.cs b/src/WorkItemMigrator/Migration.Common/UserMapper.cs index 5d138477..69cd369b 100644 --- a/src/WorkItemMigrator/Migration.Common/UserMapper.cs +++ b/src/WorkItemMigrator/Migration.Common/UserMapper.cs @@ -1,8 +1,7 @@ -using System.Collections.Generic; +using Migration.Common.Log; +using System.Collections.Generic; using System.IO; -using Migration.Common.Log; - namespace Migration.Common { public static class UserMapper diff --git a/src/WorkItemMigrator/Migration.WIContract/WiItemProvider.cs b/src/WorkItemMigrator/Migration.WIContract/WiItemProvider.cs index f058a0dd..58b6d1a0 100644 --- a/src/WorkItemMigrator/Migration.WIContract/WiItemProvider.cs +++ b/src/WorkItemMigrator/Migration.WIContract/WiItemProvider.cs @@ -1,12 +1,10 @@ -using System; +using Migration.Common.Log; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; -using Migration.Common.Log; - -using Newtonsoft.Json; - namespace Migration.WIContract { public class WiItemProvider diff --git a/src/WorkItemMigrator/WorkItemImport/Agent.cs b/src/WorkItemMigrator/WorkItemImport/Agent.cs index 2e81f75d..0bce88e8 100644 --- a/src/WorkItemMigrator/WorkItemImport/Agent.cs +++ b/src/WorkItemMigrator/WorkItemImport/Agent.cs @@ -1,24 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -using Microsoft.TeamFoundation.Core.WebApi; +using Microsoft.TeamFoundation.Core.WebApi; +using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; using Microsoft.VisualStudio.Services.Common; using Microsoft.VisualStudio.Services.Operations; - using Migration.Common; using Migration.Common.Log; using Migration.WIContract; - +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; using VsWebApi = Microsoft.VisualStudio.Services.WebApi; using WebApi = Microsoft.TeamFoundation.WorkItemTracking.WebApi; using WebModel = Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; -using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; -using System.IO; - namespace WorkItemImport { public class Agent diff --git a/src/WorkItemMigrator/WorkItemImport/ExecutionPlan.cs b/src/WorkItemMigrator/WorkItemImport/ExecutionPlan.cs index bea790cf..43b2b7c6 100644 --- a/src/WorkItemMigrator/WorkItemImport/ExecutionPlan.cs +++ b/src/WorkItemMigrator/WorkItemImport/ExecutionPlan.cs @@ -1,6 +1,6 @@ -using System.Collections.Generic; -using Migration.Common; +using Migration.Common; using Migration.WIContract; +using System.Collections.Generic; namespace WorkItemImport { diff --git a/src/WorkItemMigrator/WorkItemImport/ExecutionPlanBuilder.cs b/src/WorkItemMigrator/WorkItemImport/ExecutionPlanBuilder.cs index 7833789a..dee862dd 100644 --- a/src/WorkItemMigrator/WorkItemImport/ExecutionPlanBuilder.cs +++ b/src/WorkItemMigrator/WorkItemImport/ExecutionPlanBuilder.cs @@ -1,8 +1,8 @@ -using System; +using Migration.Common; +using Migration.Common.Log; +using System; using System.Collections.Generic; using System.IO; -using Migration.Common; -using Migration.Common.Log; namespace WorkItemImport { diff --git a/src/WorkItemMigrator/WorkItemImport/ImportCommandLine.cs b/src/WorkItemMigrator/WorkItemImport/ImportCommandLine.cs index 3e16cb1b..cdf9a4b5 100644 --- a/src/WorkItemMigrator/WorkItemImport/ImportCommandLine.cs +++ b/src/WorkItemMigrator/WorkItemImport/ImportCommandLine.cs @@ -1,16 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading; -using Common.Config; - +using Common.Config; using Microsoft.Extensions.CommandLineUtils; using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; - using Migration.Common; using Migration.Common.Config; using Migration.Common.Log; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading; namespace WorkItemImport { @@ -143,7 +141,7 @@ private bool ExecuteMigration(CommandOption token, CommandOption url, CommandOpt importedItems++; // Artifical wait (optional) to avoid throttling for ADO Services - if(config.SleepTimeBetweenRevisionImportMilliseconds > 0) + if (config.SleepTimeBetweenRevisionImportMilliseconds > 0) { Thread.Sleep(config.SleepTimeBetweenRevisionImportMilliseconds); } diff --git a/src/WorkItemMigrator/WorkItemImport/Program.cs b/src/WorkItemMigrator/WorkItemImport/Program.cs index c3af10e7..ac309f93 100644 --- a/src/WorkItemMigrator/WorkItemImport/Program.cs +++ b/src/WorkItemMigrator/WorkItemImport/Program.cs @@ -1,5 +1,5 @@ -using System; -using Migration.Common.Log; +using Migration.Common.Log; +using System; namespace WorkItemImport { diff --git a/src/WorkItemMigrator/WorkItemImport/WitClient/IWitClientWrapper.cs b/src/WorkItemMigrator/WorkItemImport/WitClient/IWitClientWrapper.cs index e1dd4365..486e270e 100644 --- a/src/WorkItemMigrator/WorkItemImport/WitClient/IWitClientWrapper.cs +++ b/src/WorkItemMigrator/WorkItemImport/WitClient/IWitClientWrapper.cs @@ -1,9 +1,9 @@ -using System; -using System.Collections.Generic; -using Microsoft.TeamFoundation.Core.WebApi; +using Microsoft.TeamFoundation.Core.WebApi; using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; using Microsoft.VisualStudio.Services.WebApi.Patch.Json; using Migration.WIContract; +using System; +using System.Collections.Generic; namespace WorkItemImport { diff --git a/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientUtils.cs b/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientUtils.cs index f467c6c5..7235012a 100644 --- a/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientUtils.cs +++ b/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientUtils.cs @@ -1,16 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; -using System.Web; -using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; +using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; using Microsoft.VisualStudio.Services.WebApi; using Microsoft.VisualStudio.Services.WebApi.Patch; using Microsoft.VisualStudio.Services.WebApi.Patch.Json; - using Migration.Common; using Migration.Common.Log; using Migration.WIContract; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using System.Web; using WorkItemImport.WitClient; namespace WorkItemImport @@ -480,13 +479,13 @@ public void SaveWorkItemAttachments(WiRevision rev, WorkItem wi) } catch (AggregateException e) { - if(e.InnerException.Message.Contains("TF237082")) + if (e.InnerException.Message.Contains("TF237082")) { Logger.Log(LogLevel.Warning, $"'{rev}' - tried to add an attachment, But the attachment exceeds " + $"the supported file upload size. Skipping attachment: {attachment.FileName}. See full error " + $"message below.\n{e.InnerException.Message}"); } - else if(e.InnerException.Message.Contains("VS403313")) + else if (e.InnerException.Message.Contains("VS403313")) { Logger.Log(LogLevel.Warning, $"'{rev}' - tried to add an attachment, but hit the workitem attachment " + $"limit (cannot add more than 100 attachments. Skipping attachment: {attachment.FileName}"); diff --git a/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientWrapper.cs b/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientWrapper.cs index d8b6c83c..e09c2a20 100644 --- a/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientWrapper.cs +++ b/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientWrapper.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading; -using Microsoft.TeamFoundation.Core.WebApi; +using Microsoft.TeamFoundation.Core.WebApi; using Microsoft.TeamFoundation.WorkItemTracking.WebApi; using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; using Microsoft.VisualStudio.Services.Common; @@ -11,6 +7,10 @@ using Microsoft.VisualStudio.Services.WebApi.Patch.Json; using Migration.Common.Log; using Migration.WIContract; +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; using WorkItemImport.WitClient; namespace WorkItemImport diff --git a/src/WorkItemMigrator/tests/Migration.Common.Tests/JsonExtensionsTests.cs b/src/WorkItemMigrator/tests/Migration.Common.Tests/JsonExtensionsTests.cs index 1df427e4..ab8e3a2d 100644 --- a/src/WorkItemMigrator/tests/Migration.Common.Tests/JsonExtensionsTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Common.Tests/JsonExtensionsTests.cs @@ -1,8 +1,7 @@ -using NUnit.Framework; - +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; using Newtonsoft.Json.Linq; +using NUnit.Framework; using System; using System.Diagnostics.CodeAnalysis; diff --git a/src/WorkItemMigrator/tests/Migration.Common.Tests/MigrationCommonTests.cs b/src/WorkItemMigrator/tests/Migration.Common.Tests/MigrationCommonTests.cs index 658fa76a..c4f4665a 100644 --- a/src/WorkItemMigrator/tests/Migration.Common.Tests/MigrationCommonTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Common.Tests/MigrationCommonTests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; - +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; -using System.Collections.Generic; using NSubstitute; -using System.IO.Abstractions; +using NUnit.Framework; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.IO.Abstractions; namespace Migration.Common.Tests { diff --git a/src/WorkItemMigrator/tests/Migration.Common.Tests/MigrationContextTests.cs b/src/WorkItemMigrator/tests/Migration.Common.Tests/MigrationContextTests.cs index a28f8232..a280941c 100644 --- a/src/WorkItemMigrator/tests/Migration.Common.Tests/MigrationContextTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Common.Tests/MigrationContextTests.cs @@ -1,10 +1,9 @@ -using NUnit.Framework; - +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; using Common.Config; -using System.IO; +using NUnit.Framework; using System.Diagnostics.CodeAnalysis; +using System.IO; namespace Migration.Common.Tests { diff --git a/src/WorkItemMigrator/tests/Migration.Common.Tests/RevisionUtilityTests.cs b/src/WorkItemMigrator/tests/Migration.Common.Tests/RevisionUtilityTests.cs index 656f9934..b441309d 100644 --- a/src/WorkItemMigrator/tests/Migration.Common.Tests/RevisionUtilityTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Common.Tests/RevisionUtilityTests.cs @@ -1,10 +1,9 @@ -using NUnit.Framework; - +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; -using System.Collections.Generic; -using System; using Migration.WIContract; +using NUnit.Framework; +using System; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace Migration.Common.Tests diff --git a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraAttachmentTest.cs b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraAttachmentTest.cs index 6c2f2fe9..9277050f 100644 --- a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraAttachmentTest.cs +++ b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraAttachmentTest.cs @@ -1,8 +1,7 @@ -using NUnit.Framework; - -using JiraExport; +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; +using JiraExport; +using NUnit.Framework; using System.Diagnostics.CodeAnalysis; namespace Migration.Jira_Export.Tests diff --git a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraChangeItemTests.cs b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraChangeItemTests.cs index 1bc2157d..becb7079 100644 --- a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraChangeItemTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraChangeItemTests.cs @@ -1,9 +1,8 @@ -using NUnit.Framework; - -using JiraExport; +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; +using JiraExport; using Newtonsoft.Json.Linq; +using NUnit.Framework; using System.Diagnostics.CodeAnalysis; namespace Migration.Jira_Export.Tests diff --git a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraCommandLineTests.cs b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraCommandLineTests.cs index 386d6335..3bffb21c 100644 --- a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraCommandLineTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraCommandLineTests.cs @@ -1,8 +1,7 @@ -using NUnit.Framework; - -using JiraExport; +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; +using JiraExport; +using NUnit.Framework; using System; using System.Diagnostics.CodeAnalysis; diff --git a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraItemTests.cs b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraItemTests.cs index 8447532a..544757e1 100644 --- a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraItemTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraItemTests.cs @@ -1,17 +1,16 @@ -using NUnit.Framework; - -using JiraExport; -using AutoFixture.AutoNSubstitute; +using Atlassian.Jira; +using Atlassian.Jira.Remote; using AutoFixture; +using AutoFixture.AutoNSubstitute; +using JiraExport; using Newtonsoft.Json.Linq; using NSubstitute; -using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; +using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; -using System; using System.Web; -using Atlassian.Jira; -using Atlassian.Jira.Remote; namespace Migration.Jira_Export.Tests { @@ -587,7 +586,7 @@ public void When_a_custom_field_is_added_Then_a_customfield_is_added_to_the_revi string customFieldId = _fixture.Create(); string customFieldName = _fixture.Create(); - var fields = JObject.Parse(@"{'issuetype': {'name': 'Story'},'"+ customFieldId + @"': {'name':'SomeValue'}}"); + var fields = JObject.Parse(@"{'issuetype': {'name': 'Story'},'" + customFieldId + @"': {'name':'SomeValue'}}"); var renderedFields = new JObject(); var changelog = new List(); @@ -634,7 +633,7 @@ public void When_a_custom_field_is_added_Then_no_customfield_is_added_to_the_rev string customFieldId = _fixture.Create(); string customFieldName = _fixture.Create(); - var fields = JObject.Parse(@"{'issuetype': {'name': 'Story'},'" + customFieldId + @"': {'name':'SomeValue', 'key':'"+ customFieldId + "'}}"); + var fields = JObject.Parse(@"{'issuetype': {'name': 'Story'},'" + customFieldId + @"': {'name':'SomeValue', 'key':'" + customFieldId + "'}}"); var renderedFields = new JObject(); var changelog = new List(); diff --git a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraLinkTests.cs b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraLinkTests.cs index af3d7400..823a8dab 100644 --- a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraLinkTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraLinkTests.cs @@ -1,8 +1,7 @@ -using NUnit.Framework; - -using JiraExport; +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; +using JiraExport; +using NUnit.Framework; using System.Diagnostics.CodeAnalysis; namespace Migration.Jira_Export.Tests diff --git a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraMapperTests.cs b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraMapperTests.cs index d7174cb2..e4802815 100644 --- a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraMapperTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraMapperTests.cs @@ -1,18 +1,17 @@ -using NUnit.Framework; - -using JiraExport; +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; -using Migration.WIContract; using Common.Config; -using System.Collections.Generic; +using JiraExport; using Migration.Common; using Migration.Common.Config; +using Migration.WIContract; using Newtonsoft.Json.Linq; using NSubstitute; +using NUnit.Framework; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using Type = Migration.Common.Config.Type; using System.Linq; +using Type = Migration.Common.Config.Type; namespace Migration.Jira_Export.Tests { @@ -201,9 +200,9 @@ public void When_calling_truncatefields_with_too_long_title_Then_a_truncated_tit { string sourceTitle = "test task with max name length - 0123456789012345678901234567890123456789012345" - +"678901234567890123456789012345678901234567890123456789012345678901234567890123" - +"456789012345678901234567890123456789012345678901234567890123456789012345678901" - +"23456789012345678901234567890"; + + "678901234567890123456789012345678901234567890123456789012345678901234567890123" + + "456789012345678901234567890123456789012345678901234567890123456789012345678901" + + "23456789012345678901234567890"; string expected = "test task with max name length - 0123456789012345678901234567890123456789012345" + "678901234567890123456789012345678901234567890123456789012345678901234567890123" @@ -211,7 +210,7 @@ public void When_calling_truncatefields_with_too_long_title_Then_a_truncated_tit + "23456789012345678..."; JiraMapper sut = createJiraMapper(); - string actual= (string)sut.TruncateField(sourceTitle, WiFieldReference.Title); + string actual = (string)sut.TruncateField(sourceTitle, WiFieldReference.Title); Assert.AreEqual(expected, actual); } diff --git a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraProviderTests.cs b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraProviderTests.cs index cac21d92..b804c3fe 100644 --- a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraProviderTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraProviderTests.cs @@ -1,13 +1,12 @@ -using NUnit.Framework; - -using JiraExport; +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; +using JiraExport; using Newtonsoft.Json.Linq; using NSubstitute; +using NUnit.Framework; using RestSharp; -using System.Linq; using System.Diagnostics.CodeAnalysis; +using System.Linq; namespace Migration.Jira_Export.Tests { diff --git a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraRevisionTests.cs b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraRevisionTests.cs index 9c89009d..d33aaf91 100644 --- a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraRevisionTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/JiraRevisionTests.cs @@ -1,10 +1,9 @@ -using NUnit.Framework; - -using JiraExport; +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; +using JiraExport; using Newtonsoft.Json.Linq; using NSubstitute; +using NUnit.Framework; using System.Diagnostics.CodeAnalysis; namespace Migration.Jira_Export.Tests diff --git a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/FieldMapperUtilsTests.cs b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/FieldMapperUtilsTests.cs index 5bab1459..834785da 100644 --- a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/FieldMapperUtilsTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/FieldMapperUtilsTests.cs @@ -1,13 +1,12 @@ -using NUnit.Framework; - +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; -using System; +using Common.Config; +using JiraExport; using Newtonsoft.Json.Linq; using NSubstitute; +using NUnit.Framework; +using System; using System.Collections.Generic; -using JiraExport; -using Common.Config; using System.Diagnostics.CodeAnalysis; namespace Migration.Jira_Export.Tests.RevisionUtils @@ -272,7 +271,7 @@ public void When_calling_map_value_with_valid_args_and_null_sourcevalue_Then_exp } } }; - + var jiraRevision = MockRevisionWithParentItem("issue_key", "My Summary"); // Ensure a null value is added to the revision jiraRevision.Fields.Add("resolution", null); diff --git a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/LinkMapperUtilsTests.cs b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/LinkMapperUtilsTests.cs index 7cc42a10..8ac2abaf 100644 --- a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/LinkMapperUtilsTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/LinkMapperUtilsTests.cs @@ -1,15 +1,14 @@ -using NUnit.Framework; - +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; -using System; +using Common.Config; +using JiraExport; +using Migration.Common.Config; +using Migration.WIContract; using Newtonsoft.Json.Linq; using NSubstitute; +using NUnit.Framework; +using System; using System.Collections.Generic; -using JiraExport; -using Migration.WIContract; -using Common.Config; -using Migration.Common.Config; using System.Diagnostics.CodeAnalysis; namespace Migration.Jira_Export.Tests.RevisionUtils diff --git a/src/WorkItemMigrator/tests/Migration.WIContract.Tests/WiFieldTests.cs b/src/WorkItemMigrator/tests/Migration.WIContract.Tests/WiFieldTests.cs index 065fe9d7..abc65ee5 100644 --- a/src/WorkItemMigrator/tests/Migration.WIContract.Tests/WiFieldTests.cs +++ b/src/WorkItemMigrator/tests/Migration.WIContract.Tests/WiFieldTests.cs @@ -1,7 +1,6 @@ -using NUnit.Framework; - using AutoFixture; using AutoFixture.AutoNSubstitute; +using NUnit.Framework; using System.Diagnostics.CodeAnalysis; namespace Migration.WIContract.Tests diff --git a/src/WorkItemMigrator/tests/Migration.WIContract.Tests/WiItemTests.cs b/src/WorkItemMigrator/tests/Migration.WIContract.Tests/WiItemTests.cs index 92a542fa..b1a32578 100644 --- a/src/WorkItemMigrator/tests/Migration.WIContract.Tests/WiItemTests.cs +++ b/src/WorkItemMigrator/tests/Migration.WIContract.Tests/WiItemTests.cs @@ -1,7 +1,6 @@ -using NUnit.Framework; - using AutoFixture; using AutoFixture.AutoNSubstitute; +using NUnit.Framework; using System.Diagnostics.CodeAnalysis; namespace Migration.WIContract.Tests diff --git a/src/WorkItemMigrator/tests/Migration.WIContract.Tests/WiRevisionTests.cs b/src/WorkItemMigrator/tests/Migration.WIContract.Tests/WiRevisionTests.cs index dc54d8f0..d4b3a1aa 100644 --- a/src/WorkItemMigrator/tests/Migration.WIContract.Tests/WiRevisionTests.cs +++ b/src/WorkItemMigrator/tests/Migration.WIContract.Tests/WiRevisionTests.cs @@ -1,7 +1,6 @@ -using NUnit.Framework; - using AutoFixture; using AutoFixture.AutoNSubstitute; +using NUnit.Framework; using System.Diagnostics.CodeAnalysis; namespace Migration.WIContract.Tests diff --git a/src/WorkItemMigrator/tests/Migration.Wi-Import.Tests/ImportCommandLineTests.cs b/src/WorkItemMigrator/tests/Migration.Wi-Import.Tests/ImportCommandLineTests.cs index f6fdd6bc..5c476c39 100644 --- a/src/WorkItemMigrator/tests/Migration.Wi-Import.Tests/ImportCommandLineTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Wi-Import.Tests/ImportCommandLineTests.cs @@ -1,10 +1,9 @@ -using NUnit.Framework; - +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; +using NUnit.Framework; using System; -using WorkItemImport; using System.Diagnostics.CodeAnalysis; +using WorkItemImport; namespace Migration.Wi_Import.Tests { diff --git a/src/WorkItemMigrator/tests/Migration.Wi-Import.Tests/WitClient/JsonPatchDocUtilsTests.cs b/src/WorkItemMigrator/tests/Migration.Wi-Import.Tests/WitClient/JsonPatchDocUtilsTests.cs index a557612d..36dd3e15 100644 --- a/src/WorkItemMigrator/tests/Migration.Wi-Import.Tests/WitClient/JsonPatchDocUtilsTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Wi-Import.Tests/WitClient/JsonPatchDocUtilsTests.cs @@ -1,15 +1,11 @@ -using NUnit.Framework; - +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; -using System; -using Microsoft.VisualStudio.Services.WebApi.Patch.Json; using Microsoft.VisualStudio.Services.WebApi.Patch; - +using Microsoft.VisualStudio.Services.WebApi.Patch.Json; +using NUnit.Framework; +using System; using System.Diagnostics.CodeAnalysis; using WorkItemImport.WitClient; -using Newtonsoft.Json.Linq; -using Microsoft.VisualStudio.Services.Common; using static WorkItemImport.WitClient.JsonPatchDocUtils; namespace Migration.Wi_Import.Tests diff --git a/src/WorkItemMigrator/tests/Migration.Wi-Import.Tests/WitClient/WitClientUtilsTests.cs b/src/WorkItemMigrator/tests/Migration.Wi-Import.Tests/WitClient/WitClientUtilsTests.cs index d316f5ff..105a75fb 100644 --- a/src/WorkItemMigrator/tests/Migration.Wi-Import.Tests/WitClient/WitClientUtilsTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Wi-Import.Tests/WitClient/WitClientUtilsTests.cs @@ -1,20 +1,18 @@ -using NUnit.Framework; - +using AutoFixture; using AutoFixture.AutoNSubstitute; -using AutoFixture; -using System; -using WorkItemImport; -using Migration.WIContract; -using System.Collections.Generic; -using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; using Microsoft.TeamFoundation.Core.WebApi; -using Microsoft.VisualStudio.Services.WebApi.Patch.Json; +using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; +using Microsoft.VisualStudio.Services.WebApi; using Microsoft.VisualStudio.Services.WebApi.Patch; -using System.Linq; - +using Microsoft.VisualStudio.Services.WebApi.Patch.Json; using Migration.Common; -using Microsoft.VisualStudio.Services.WebApi; +using Migration.WIContract; +using NUnit.Framework; +using System; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Linq; +using WorkItemImport; namespace Migration.Wi_Import.Tests { @@ -68,7 +66,7 @@ public WorkItem UpdateWorkItem(JsonPatchDocument patchDocument, int workItemId) else if (op.Path.StartsWith("/relations/")) { string rel = op.Value.GetType().GetProperty("rel")?.GetValue(op.Value, null).ToString(); - if(rel == null) + if (rel == null) { rel = op.Value.GetType().GetProperty("Rel")?.GetValue(op.Value, null).ToString(); }