From 4cd02cc6f3c62389c2e33457475264fea20698e1 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Thu, 25 Jul 2024 16:46:42 +0100 Subject: [PATCH 01/14] =?UTF-8?q?=F0=9F=90=9B=20(EngineConfigurationBuilde?= =?UTF-8?q?r.cs):=20replace=20exception=20with=20critical=20log=20and=20ex?= =?UTF-8?q?it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The change replaces a thrown exception with a critical log message and a call to `System.Environment.Exit(-1)`. This ensures that the application logs the critical error before terminating, providing better diagnostics and a clearer shutdown process. --- .../_EngineV1/Configuration/EngineConfigurationBuilder.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MigrationTools/_EngineV1/Configuration/EngineConfigurationBuilder.cs b/src/MigrationTools/_EngineV1/Configuration/EngineConfigurationBuilder.cs index b210bed3d..cf109d725 100644 --- a/src/MigrationTools/_EngineV1/Configuration/EngineConfigurationBuilder.cs +++ b/src/MigrationTools/_EngineV1/Configuration/EngineConfigurationBuilder.cs @@ -79,7 +79,8 @@ public EngineConfiguration BuildFromFile(string configFile = "configuration.json } else { - throw new Exception("Version in Config does not match X.X in Application. Please check and revert."); + _logger.LogCritical("Version in Config does not match X.X in Application. Please check and revert."); + System.Environment.Exit(-1); } } //#endif From 1cc90efac5b8f8d65e28e8698a484e06c8034044 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Thu, 25 Jul 2024 18:15:23 +0100 Subject: [PATCH 02/14] =?UTF-8?q?=F0=9F=93=9D=20(docs):=20update=20Migrati?= =?UTF-8?q?onTools=20documentation=20to=20reflect=20new=20WorkItemBulkEdit?= =?UTF-8?q?ProcessorConfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor the documentation to replace references to WorkItemUpdateConfig with WorkItemBulkEditProcessorConfig. This change ensures that the documentation accurately reflects the current configuration class names and their associated properties. Additionally, update the Git metadata to reflect the latest commit and branch information. This improves clarity and accuracy in the documentation, making it easier for users to understand and configure the migration tools. 📝 (docs): add documentation for WorkItemBulkEditProcessor ♻️ (config): rename WorkItemUpdateConfig to WorkItemBulkEditProcessorConfig ♻️ (processor): rename WorkItemUpdate to WorkItemBulkEditProcessor 💡 (comments): update comments to reflect new class names The documentation for the `WorkItemBulkEditProcessor` is added to provide users with configuration details and usage examples. The class `WorkItemUpdateConfig` is renamed to `WorkItemBulkEditProcessorConfig` to better reflect its purpose. Similarly, the processor class `WorkItemUpdate` is renamed to `WorkItemBulkEditProcessor` for consistency. Comments and references in the code are updated to match the new class names, improving code readability and maintainability. --- docs/Reference/Generated/MigrationTools.xml | 28 +++++++++---------- .../Generated/VstsSyncMigrator.Core.xml | 2 +- ...processors.workitembulkeditprocessor.yaml} | 14 +++++----- ...1.processors.workitembulkeditprocessor.md} | 22 +++++++-------- .../EngineConfigurationBuilder.cs | 4 +-- .../Processing/WorkItemUpdateConfig.cs | 6 ++-- .../ProcessingContext/WorkItemDelete.cs | 2 +- .../ProcessingContext/WorkItemUpdate.cs | 8 +++--- .../ServiceCollectionExtensions.cs | 2 +- 9 files changed, 44 insertions(+), 44 deletions(-) rename docs/_data/{reference.v1.processors.workitemupdate.yaml => reference.v1.processors.workitembulkeditprocessor.yaml} (88%) rename docs/collections/_reference/{reference.v1.processors.workitemupdate.md => reference.v1.processors.workitembulkeditprocessor.md} (83%) diff --git a/docs/Reference/Generated/MigrationTools.xml b/docs/Reference/Generated/MigrationTools.xml index d51c4e74b..3c23279a4 100644 --- a/docs/Reference/Generated/MigrationTools.xml +++ b/docs/Reference/Generated/MigrationTools.xml @@ -541,39 +541,39 @@ - + A work item query based on WIQL to select only important work items. To migrate all leave this empty. See [WIQL Query Bits](#wiql-query-bits) AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') - + A list of work items to import [] - + This loads all of the work items already saved to the Target and removes them from the Source work item list prior to commencing the run. While this may take some time in large data sets it reduces the time of the overall migration significantly if you need to restart. true - + Pause after each work item is migrated false - + **beta** If set to a number greater than 0 work items that fail to save will retry after a number of seconds equal to the retry count. This allows for periodic network glitches not to end the process. 5 - + @@ -594,7 +594,7 @@ - => @"false" + => @"true" @@ -604,32 +604,32 @@ - => @"topic/move-cmd" + => @"feature/small-changes-group-1" - => @"3a2c737" + => @"4cd02cc" - => @"3a2c737011911c5b1e68261733d02c1ef8f40cc1" + => @"4cd02cc6f3c62389c2e33457475264fea20698e1" - => @"2024-07-25T13:50:46+01:00" + => @"2024-07-25T16:46:42+01:00" - => @"11" + => @"15" - => @"v15.1.5-Preview.2-11-g3a2c737" + => @"v15.1.5-Preview.2-15-g4cd02cc" @@ -664,7 +664,7 @@ - => @"16" + => @"20" diff --git a/docs/Reference/Generated/VstsSyncMigrator.Core.xml b/docs/Reference/Generated/VstsSyncMigrator.Core.xml index 63c78e83e..0c83a2e80 100644 --- a/docs/Reference/Generated/VstsSyncMigrator.Core.xml +++ b/docs/Reference/Generated/VstsSyncMigrator.Core.xml @@ -131,7 +131,7 @@ ready WorkItem - + This processor allows you to make changes in place where we load from teh Target and update the Target. This is used for bulk updates with the most common reason being a process template change. diff --git a/docs/_data/reference.v1.processors.workitemupdate.yaml b/docs/_data/reference.v1.processors.workitembulkeditprocessor.yaml similarity index 88% rename from docs/_data/reference.v1.processors.workitemupdate.yaml rename to docs/_data/reference.v1.processors.workitembulkeditprocessor.yaml index 8b64b0fd6..49dd58685 100644 --- a/docs/_data/reference.v1.processors.workitemupdate.yaml +++ b/docs/_data/reference.v1.processors.workitembulkeditprocessor.yaml @@ -1,11 +1,11 @@ -optionsClassName: WorkItemUpdateConfig -optionsClassFullName: MigrationTools._EngineV1.Configuration.Processing.WorkItemUpdateConfig +optionsClassName: WorkItemBulkEditProcessorConfig +optionsClassFullName: MigrationTools._EngineV1.Configuration.Processing.WorkItemBulkEditProcessorConfig configurationSamples: - name: default description: code: >- { - "$type": "WorkItemUpdateConfig", + "$type": "WorkItemBulkEditProcessorConfig", "Enabled": false, "WhatIf": false, "WIQLQuery": "SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [@ReflectedWorkItemIdFieldName] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') ORDER BY [System.ChangedDate] desc", @@ -14,9 +14,9 @@ configurationSamples: "PauseAfterEachWorkItem": false, "WorkItemCreateRetryLimit": 0 } - sampleFor: MigrationTools._EngineV1.Configuration.Processing.WorkItemUpdateConfig + sampleFor: MigrationTools._EngineV1.Configuration.Processing.WorkItemBulkEditProcessorConfig description: This processor allows you to make changes in place where we load from teh Target and update the Target. This is used for bulk updates with the most common reason being a process template change. -className: WorkItemUpdate +className: WorkItemBulkEditProcessor typeName: Processors architecture: v1 options: @@ -50,5 +50,5 @@ options: defaultValue: '[]' status: missng XML code comments processingTarget: WorkItem -classFile: /src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemUpdate.cs -optionsClassFile: /src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemUpdateConfig.cs +classFile: '' +optionsClassFile: '' diff --git a/docs/collections/_reference/reference.v1.processors.workitemupdate.md b/docs/collections/_reference/reference.v1.processors.workitembulkeditprocessor.md similarity index 83% rename from docs/collections/_reference/reference.v1.processors.workitemupdate.md rename to docs/collections/_reference/reference.v1.processors.workitembulkeditprocessor.md index 6dda7c76b..3fbf25760 100644 --- a/docs/collections/_reference/reference.v1.processors.workitemupdate.md +++ b/docs/collections/_reference/reference.v1.processors.workitembulkeditprocessor.md @@ -1,12 +1,12 @@ --- -optionsClassName: WorkItemUpdateConfig -optionsClassFullName: MigrationTools._EngineV1.Configuration.Processing.WorkItemUpdateConfig +optionsClassName: WorkItemBulkEditProcessorConfig +optionsClassFullName: MigrationTools._EngineV1.Configuration.Processing.WorkItemBulkEditProcessorConfig configurationSamples: - name: default description: code: >- { - "$type": "WorkItemUpdateConfig", + "$type": "WorkItemBulkEditProcessorConfig", "Enabled": false, "WhatIf": false, "WIQLQuery": "SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [@ReflectedWorkItemIdFieldName] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') ORDER BY [System.ChangedDate] desc", @@ -15,9 +15,9 @@ configurationSamples: "PauseAfterEachWorkItem": false, "WorkItemCreateRetryLimit": 0 } - sampleFor: MigrationTools._EngineV1.Configuration.Processing.WorkItemUpdateConfig + sampleFor: MigrationTools._EngineV1.Configuration.Processing.WorkItemBulkEditProcessorConfig description: This processor allows you to make changes in place where we load from teh Target and update the Target. This is used for bulk updates with the most common reason being a process template change. -className: WorkItemUpdate +className: WorkItemBulkEditProcessor typeName: Processors architecture: v1 options: @@ -51,24 +51,24 @@ options: defaultValue: '[]' status: missng XML code comments processingTarget: WorkItem -classFile: /src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemUpdate.cs -optionsClassFile: /src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemUpdateConfig.cs +classFile: '' +optionsClassFile: '' redirectFrom: [] layout: reference toc: true -permalink: /Reference/v1/Processors/WorkItemUpdate/ -title: WorkItemUpdate +permalink: /Reference/v1/Processors/WorkItemBulkEditProcessor/ +title: WorkItemBulkEditProcessor categories: - Processors - v1 topics: - topic: notes - path: /docs/Reference/v1/Processors/WorkItemUpdate-notes.md + path: /docs/Reference/v1/Processors/WorkItemBulkEditProcessor-notes.md exists: false markdown: '' - topic: introduction - path: /docs/Reference/v1/Processors/WorkItemUpdate-introduction.md + path: /docs/Reference/v1/Processors/WorkItemBulkEditProcessor-introduction.md exists: false markdown: '' diff --git a/src/MigrationTools/_EngineV1/Configuration/EngineConfigurationBuilder.cs b/src/MigrationTools/_EngineV1/Configuration/EngineConfigurationBuilder.cs index cf109d725..3d40bfe5a 100644 --- a/src/MigrationTools/_EngineV1/Configuration/EngineConfigurationBuilder.cs +++ b/src/MigrationTools/_EngineV1/Configuration/EngineConfigurationBuilder.cs @@ -108,7 +108,7 @@ public EngineConfiguration BuildDefault() ec.Processors.Add(new ImportProfilePictureConfig()); ec.Processors.Add(new ExportProfilePictureFromADConfig()); ec.Processors.Add(new FixGitCommitLinksConfig() { TargetRepository = "targetProjectName" }); - ec.Processors.Add(new WorkItemUpdateConfig()); + ec.Processors.Add(new WorkItemBulkEditProcessorConfig()); ec.Processors.Add(new WorkItemPostProcessingConfig() { WorkItemIDs = new List { 1, 2, 3 } }); ec.Processors.Add(new WorkItemDeleteConfig()); ec.Processors.Add(new WorkItemQueryMigrationConfig() { SourceToTargetFieldMappings = new Dictionary() { { "SourceFieldRef", "TargetFieldRef" } } }); @@ -125,7 +125,7 @@ public EngineConfiguration BuildReference() ec.Processors.Add(new ImportProfilePictureConfig()); ec.Processors.Add(new ExportProfilePictureFromADConfig()); ec.Processors.Add(new FixGitCommitLinksConfig() { TargetRepository = "targetProjectName" }); - ec.Processors.Add(new WorkItemUpdateConfig()); + ec.Processors.Add(new WorkItemBulkEditProcessorConfig()); ec.Processors.Add(new WorkItemPostProcessingConfig() { WorkItemIDs = new List { 1, 2, 3 } }); ec.Processors.Add(new WorkItemDeleteConfig()); ec.Processors.Add(new WorkItemQueryMigrationConfig() { SourceToTargetFieldMappings = new Dictionary() { { "SourceFieldRef", "TargetFieldRef" } } }); diff --git a/src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemUpdateConfig.cs b/src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemUpdateConfig.cs index 9613c83d1..5407ec33e 100644 --- a/src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemUpdateConfig.cs +++ b/src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemUpdateConfig.cs @@ -2,7 +2,7 @@ namespace MigrationTools._EngineV1.Configuration.Processing { - public class WorkItemUpdateConfig : IWorkItemProcessorConfig + public class WorkItemBulkEditProcessorConfig : IWorkItemProcessorConfig { public bool WhatIf { get; set; } @@ -10,7 +10,7 @@ public class WorkItemUpdateConfig : IWorkItemProcessorConfig public string Processor { - get { return "WorkItemUpdate"; } + get { return "WorkItemBulkEditProcessor"; } } /// @@ -52,7 +52,7 @@ public bool IsProcessorCompatible(IReadOnlyList otherProcessor return true; } - public WorkItemUpdateConfig() + public WorkItemBulkEditProcessorConfig() { WIQLQuery = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [@ReflectedWorkItemIdFieldName] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') ORDER BY [System.ChangedDate] desc"; } diff --git a/src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemDelete.cs b/src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemDelete.cs index e2ae0793f..103319151 100644 --- a/src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemDelete.cs +++ b/src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemDelete.cs @@ -22,7 +22,7 @@ public class WorkItemDelete : StaticProcessorBase { private WorkItemDeleteConfig _config; - public WorkItemDelete(IServiceProvider services, IMigrationEngine me, ITelemetryLogger telemetry, ILogger logger) + public WorkItemDelete(IServiceProvider services, IMigrationEngine me, ITelemetryLogger telemetry, ILogger logger) : base(services, me, telemetry, logger) { } diff --git a/src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemUpdate.cs b/src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemUpdate.cs index 13cbd72b5..b2c5841dd 100644 --- a/src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemUpdate.cs +++ b/src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemUpdate.cs @@ -14,17 +14,17 @@ namespace VstsSyncMigrator.Engine /// This processor allows you to make changes in place where we load from teh Target and update the Target. This is used for bulk updates with the most common reason being a process template change. /// /// WorkItem - public class WorkItemUpdate : StaticProcessorBase + public class WorkItemBulkEditProcessor : StaticProcessorBase { - private WorkItemUpdateConfig _config; + private WorkItemBulkEditProcessorConfig _config; - public WorkItemUpdate(IServiceProvider services, IMigrationEngine me, ITelemetryLogger telemetry, ILogger logger) : base(services, me, telemetry, logger) + public WorkItemBulkEditProcessor(IServiceProvider services, IMigrationEngine me, ITelemetryLogger telemetry, ILogger logger) : base(services, me, telemetry, logger) { } public override void Configure(IProcessorConfig config) { - _config = (WorkItemUpdateConfig)config; + _config = (WorkItemBulkEditProcessorConfig)config; } public override string Name diff --git a/src/VstsSyncMigrator.Core/ServiceCollectionExtensions.cs b/src/VstsSyncMigrator.Core/ServiceCollectionExtensions.cs index 919a07dc4..93c01148b 100644 --- a/src/VstsSyncMigrator.Core/ServiceCollectionExtensions.cs +++ b/src/VstsSyncMigrator.Core/ServiceCollectionExtensions.cs @@ -24,7 +24,7 @@ public static void AddMigrationToolServicesForClientLegacyCore(this IServiceColl context.AddSingleton(); context.AddSingleton(); context.AddSingleton(); - context.AddSingleton(); + context.AddSingleton(); context.AddSingleton(); } From 127a845169a2b72b83985b6c0d935732dedcd785 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Thu, 25 Jul 2024 18:16:53 +0100 Subject: [PATCH 03/14] =?UTF-8?q?=E2=9C=A8=20(WorkItemBulkEditProcessor):?= =?UTF-8?q?=20add=20new=20processor=20for=20bulk=20editing=20work=20items?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce `WorkItemBulkEditProcessor` and its configuration class `WorkItemBulkEditProcessorConfig`. This processor allows bulk updates to work items, primarily for scenarios like process template changes. The new processor supports: - Configurable WIQL queries to select work items. - Option to filter out work items that already exist in the target. - Retry mechanism for work item save failures. - "What If" mode to simulate changes without saving. These changes enhance the flexibility and robustness of the migration tool by enabling bulk updates and providing mechanisms to handle common issues during migration. --- ...WorkItemUpdateConfig.cs => WorkItemBulkEditProcessorConfig.cs} | 0 .../{WorkItemUpdate.cs => WorkItemBulkEditProcessor.cs} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/MigrationTools/_EngineV1/Configuration/Processing/{WorkItemUpdateConfig.cs => WorkItemBulkEditProcessorConfig.cs} (100%) rename src/VstsSyncMigrator.Core/Execution/ProcessingContext/{WorkItemUpdate.cs => WorkItemBulkEditProcessor.cs} (100%) diff --git a/src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemUpdateConfig.cs b/src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemBulkEditProcessorConfig.cs similarity index 100% rename from src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemUpdateConfig.cs rename to src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemBulkEditProcessorConfig.cs diff --git a/src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemUpdate.cs b/src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemBulkEditProcessor.cs similarity index 100% rename from src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemUpdate.cs rename to src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemBulkEditProcessor.cs From 7acec2e6266f5f05b2807264ee8f1db7b94b1949 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Thu, 25 Jul 2024 18:26:18 +0100 Subject: [PATCH 04/14] =?UTF-8?q?=F0=9F=93=9D=20(docs):=20update=20Migrati?= =?UTF-8?q?onTools=20and=20VstsSyncMigrator.Core=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add new members to `MigrationTools.xml` for `WorkItemBulkEditProcessorConfig` properties. Correct the class and options class file paths in `workitembulkeditprocessor.yaml` and `workitembulkeditprocessor.md`. Swap the descriptions for `WorkItemDelete` and `WorkItemBulkEditProcessor` in `VstsSyncMigrator.Core.xml`. These changes ensure that the documentation accurately reflects the current state of the codebase, providing correct paths and descriptions for better clarity and usability. --- docs/Reference/Generated/MigrationTools.xml | 82 +++++++++---------- .../Generated/VstsSyncMigrator.Core.xml | 12 +-- ....processors.workitembulkeditprocessor.yaml | 4 +- ...v1.processors.workitembulkeditprocessor.md | 5 +- 4 files changed, 51 insertions(+), 52 deletions(-) diff --git a/docs/Reference/Generated/MigrationTools.xml b/docs/Reference/Generated/MigrationTools.xml index 3c23279a4..9575cbd67 100644 --- a/docs/Reference/Generated/MigrationTools.xml +++ b/docs/Reference/Generated/MigrationTools.xml @@ -344,6 +344,41 @@ + + + A work item query based on WIQL to select only important work items. To migrate all leave this empty. See [WIQL Query Bits](#wiql-query-bits) + + AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') + + + + A list of work items to import + + [] + + + + This loads all of the work items already saved to the Target and removes them from the Source work item list prior to commencing the run. + While this may take some time in large data sets it reduces the time of the overall migration significantly if you need to restart. + + true + + + + Pause after each work item is migrated + + false + + + + **beta** If set to a number greater than 0 work items that fail to save will retry after a number of seconds equal to the retry count. + This allows for periodic network glitches not to end the process. + + 5 + + + + @@ -541,41 +576,6 @@ - - - A work item query based on WIQL to select only important work items. To migrate all leave this empty. See [WIQL Query Bits](#wiql-query-bits) - - AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') - - - - A list of work items to import - - [] - - - - This loads all of the work items already saved to the Target and removes them from the Source work item list prior to commencing the run. - While this may take some time in large data sets it reduces the time of the overall migration significantly if you need to restart. - - true - - - - Pause after each work item is migrated - - false - - - - **beta** If set to a number greater than 0 work items that fail to save will retry after a number of seconds equal to the retry count. - This allows for periodic network glitches not to end the process. - - 5 - - - - from https://gist.github.com/pietergheysens/792ed505f09557e77ddfc1b83531e4fb @@ -609,27 +609,27 @@ - => @"4cd02cc" + => @"127a845" - => @"4cd02cc6f3c62389c2e33457475264fea20698e1" + => @"127a845169a2b72b83985b6c0d935732dedcd785" - => @"2024-07-25T16:46:42+01:00" + => @"2024-07-25T18:16:53+01:00" - => @"15" + => @"17" - => @"v15.1.5-Preview.2-15-g4cd02cc" + => @"v15.1.5-Preview.2-17-g127a845" @@ -664,7 +664,7 @@ - => @"20" + => @"22" diff --git a/docs/Reference/Generated/VstsSyncMigrator.Core.xml b/docs/Reference/Generated/VstsSyncMigrator.Core.xml index 0c83a2e80..c415a50c4 100644 --- a/docs/Reference/Generated/VstsSyncMigrator.Core.xml +++ b/docs/Reference/Generated/VstsSyncMigrator.Core.xml @@ -123,18 +123,18 @@ alpha Profiles - + - The `WorkItemDelete` processor allows you to delete any amount of work items that meet the query. - **DANGER:** This is not a recoverable action and should be use with extream caution. + This processor allows you to make changes in place where we load from teh Target and update the Target. This is used for bulk updates with the most common reason being a process template change. - ready WorkItem - + - This processor allows you to make changes in place where we load from teh Target and update the Target. This is used for bulk updates with the most common reason being a process template change. + The `WorkItemDelete` processor allows you to delete any amount of work items that meet the query. + **DANGER:** This is not a recoverable action and should be use with extream caution. + ready WorkItem diff --git a/docs/_data/reference.v1.processors.workitembulkeditprocessor.yaml b/docs/_data/reference.v1.processors.workitembulkeditprocessor.yaml index 49dd58685..6d4f96c92 100644 --- a/docs/_data/reference.v1.processors.workitembulkeditprocessor.yaml +++ b/docs/_data/reference.v1.processors.workitembulkeditprocessor.yaml @@ -50,5 +50,5 @@ options: defaultValue: '[]' status: missng XML code comments processingTarget: WorkItem -classFile: '' -optionsClassFile: '' +classFile: /src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemBulkEditProcessor.cs +optionsClassFile: /src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemBulkEditProcessorConfig.cs diff --git a/docs/collections/_reference/reference.v1.processors.workitembulkeditprocessor.md b/docs/collections/_reference/reference.v1.processors.workitembulkeditprocessor.md index 3fbf25760..a1be1281c 100644 --- a/docs/collections/_reference/reference.v1.processors.workitembulkeditprocessor.md +++ b/docs/collections/_reference/reference.v1.processors.workitembulkeditprocessor.md @@ -51,9 +51,8 @@ options: defaultValue: '[]' status: missng XML code comments processingTarget: WorkItem -classFile: '' -optionsClassFile: '' - +classFile: /src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemBulkEditProcessor.cs +optionsClassFile: /src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemBulkEditProcessorConfig.cs redirectFrom: [] layout: reference toc: true From bfd206b3abbb82247f804cca802b4188e2f5c2d2 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Fri, 26 Jul 2024 09:09:36 +0100 Subject: [PATCH 05/14] =?UTF-8?q?=F0=9F=93=9D=20(docs):=20update=20Migrati?= =?UTF-8?q?onTools.xml=20with=20new=20commit=20details?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the XML documentation to reflect the latest commit details, including the new commit hash, commit date, and version information. ✅ (tests): add unit tests for DetectVersionService2 Add new unit tests to ensure the `GetRunningVersion` method works correctly for different version types: Release, Preview, and Canary. This improves test coverage and ensures the method handles various version formats correctly. ✨ (tests): create FakeMigrationToolVersionInfo for testing Introduce a `FakeMigrationToolVersionInfo` class to mock version information in unit tests. This allows for more controlled and predictable testing of version-related functionality. ♻️ (host): refactor DetectVersionService2 to accept version info Modify `DetectVersionService2.GetRunningVersion` to accept an optional `IMigrationToolVersionInfo` parameter. This change improves testability and flexibility by allowing the method to use provided version information instead of always fetching it from the assembly. ♻️ (host): add LoggerHasBeenBuilt flag to MigrationToolHost Introduce a `LoggerHasBeenBuilt` flag to ensure the logger is only built once. This prevents potential issues with multiple logger instances and ensures consistent logging behavior. ✨ (MigrationToolVersionInfo): add MigrationToolVersionInfo service to provide version information Introduce a new service `MigrationToolVersionInfo` that implements the `IMigrationToolVersionInfo` interface. This service provides version information such as `ProductVersion`, `FileVersion`, and `GitTag`. This addition helps in tracking and displaying the version details of the migration tool, which is useful for debugging and auditing purposes. --- docs/Reference/Generated/MigrationTools.xml | 12 ++--- .../Services/DetectVersionService2Tests.cs | 26 +++++++++- .../Services/FakeMigrationToolVersionInfo.cs | 25 ++++++++++ src/MigrationTools.Host/MigrationToolHost.cs | 47 ++++++++++--------- .../Services/DetectVersionService2.cs | 27 ++++++----- .../Services/MigrationToolVersionInfo.cs | 43 +++++++++++++++++ .../EngineConfigurationBuilder.cs | 1 + 7 files changed, 142 insertions(+), 39 deletions(-) create mode 100644 src/MigrationTools.Host.Tests/Services/FakeMigrationToolVersionInfo.cs create mode 100644 src/MigrationTools.Host/Services/MigrationToolVersionInfo.cs diff --git a/docs/Reference/Generated/MigrationTools.xml b/docs/Reference/Generated/MigrationTools.xml index 9575cbd67..c8a59b261 100644 --- a/docs/Reference/Generated/MigrationTools.xml +++ b/docs/Reference/Generated/MigrationTools.xml @@ -609,27 +609,27 @@ - => @"127a845" + => @"7acec2e" - => @"127a845169a2b72b83985b6c0d935732dedcd785" + => @"7acec2e6266f5f05b2807264ee8f1db7b94b1949" - => @"2024-07-25T18:16:53+01:00" + => @"2024-07-25T18:26:18+01:00" - => @"17" + => @"18" - => @"v15.1.5-Preview.2-17-g127a845" + => @"v15.1.5-Preview.2-18-g7acec2e" @@ -664,7 +664,7 @@ - => @"22" + => @"23" diff --git a/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs b/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs index 25338dfed..c94010b5b 100644 --- a/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs +++ b/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs @@ -1,9 +1,11 @@ -using Microsoft.Extensions.DependencyInjection; +using MigrationTools.Host.Services; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; using MigrationTools.Services; using Serilog; using Serilog.Events; +using MigrationTools.Host.Tests.Services; namespace MigrationTools.Host.Services.Tests { @@ -31,6 +33,28 @@ public void DetectVersionServiceTest_Initialise() } + [TestMethod(), TestCategory("L0")] + public void GetRunningVersionTest_Release() + { + IMigrationToolVersionInfo versionInfo = new FakeMigrationToolVersionInfo("15.4.4", "15.4.4.0", "v15.4.4"); + var result = DetectVersionService2.GetRunningVersion(versionInfo); + Assert.AreEqual("15.4.4", result.versionString); + } + [TestMethod(), TestCategory("L0")] + public void GetRunningVersionTest_Preview() + { + IMigrationToolVersionInfo versionInfo = new FakeMigrationToolVersionInfo("15.1.5-Preview.3", "15.1.5.3", "v15.1.5-Preview.3"); + var result = DetectVersionService2.GetRunningVersion(versionInfo); + Assert.AreEqual("15.1.5-Preview.3", result.versionString); + } + + [TestMethod(), TestCategory("L0")] + public void GetRunningVersionTest_Canary() + { + IMigrationToolVersionInfo versionInfo = new FakeMigrationToolVersionInfo("0.0.0-local+7acec2e6266f5f05b2807264ee8f1db7b94b1949", "0.0.0.0", "v15.1.5-Preview.2-18-g7acec2e"); + var result = DetectVersionService2.GetRunningVersion(versionInfo); + Assert.AreEqual("15.1.5-Local.2-18-g7acec2e", result.versionString); + } } } \ No newline at end of file diff --git a/src/MigrationTools.Host.Tests/Services/FakeMigrationToolVersionInfo.cs b/src/MigrationTools.Host.Tests/Services/FakeMigrationToolVersionInfo.cs new file mode 100644 index 000000000..4536c1f17 --- /dev/null +++ b/src/MigrationTools.Host.Tests/Services/FakeMigrationToolVersionInfo.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using MigrationTools.Host.Services; + +namespace MigrationTools.Host.Tests.Services +{ + class FakeMigrationToolVersionInfo : IMigrationToolVersionInfo + { + public string ProductVersion { get; private set; } + public string FileVersion { get; private set; } + public string GitTag { get; private set; } + + public FakeMigrationToolVersionInfo(string productVersion, string fileVersion, string gitTag) + { + ProductVersion = productVersion; + FileVersion = fileVersion; + GitTag = gitTag; + } + } +} diff --git a/src/MigrationTools.Host/MigrationToolHost.cs b/src/MigrationTools.Host/MigrationToolHost.cs index c20b79e62..6f6f660f8 100644 --- a/src/MigrationTools.Host/MigrationToolHost.cs +++ b/src/MigrationTools.Host/MigrationToolHost.cs @@ -27,9 +27,13 @@ namespace MigrationTools.Host { + + + public static class MigrationToolHost { static int logs = 1; + private static bool LoggerHasBeenBuilt = false; public static IHostBuilder CreateDefaultBuilder(string[] args) { @@ -39,27 +43,28 @@ public static IHostBuilder CreateDefaultBuilder(string[] args) hostBuilder.UseSerilog((hostingContext, services, loggerConfiguration) => { - string outputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] [" + DetectVersionService2.GetRunningVersion().versionString + "] {Message:lj}{NewLine}{Exception}"; // {SourceContext} - string logsPath = CreateLogsPath(); - var logPath = Path.Combine(logsPath, $"migration{logs}.log"); - - var logLevel = hostingContext.Configuration.GetValue("LogLevel"); - var levelSwitch = new LoggingLevelSwitch(logLevel); - loggerConfiguration - .MinimumLevel.ControlledBy(levelSwitch) - .ReadFrom.Configuration(hostingContext.Configuration) - .Enrich.FromLogContext() - .Enrich.WithMachineName() - .Enrich.WithProcessId() - .WriteTo.File(logPath, LogEventLevel.Verbose, outputTemplate) - .WriteTo.Logger(lc => lc - .Filter.ByExcluding(Matching.FromSource("Microsoft")) - .Filter.ByExcluding(Matching.FromSource("MigrationTools.Host.StartupService")) - .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Debug, theme: AnsiConsoleTheme.Code, outputTemplate: outputTemplate)) - .WriteTo.Logger(lc => lc - .Filter.ByExcluding(Matching.FromSource("Microsoft")) - .WriteTo.ApplicationInsights(services.GetService(), new CustomConverter(), LogEventLevel.Error)); - logs++; + string outputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] [" + DetectVersionService2.GetRunningVersion().versionString + "] {Message:lj}{NewLine}{Exception}"; // {SourceContext} + string logsPath = CreateLogsPath(); + var logPath = Path.Combine(logsPath, $"migration-{logs}.log"); + + var logLevel = hostingContext.Configuration.GetValue("LogLevel"); + var levelSwitch = new LoggingLevelSwitch(logLevel); + loggerConfiguration + .MinimumLevel.ControlledBy(levelSwitch) + .ReadFrom.Configuration(hostingContext.Configuration) + .Enrich.FromLogContext() + .Enrich.WithMachineName() + .Enrich.WithProcessId() + .WriteTo.File(logPath, LogEventLevel.Verbose, outputTemplate) + .WriteTo.Logger(lc => lc + .Filter.ByExcluding(Matching.FromSource("Microsoft")) + .Filter.ByExcluding(Matching.FromSource("MigrationTools.Host.StartupService")) + .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Debug, theme: AnsiConsoleTheme.Code, outputTemplate: outputTemplate)) + .WriteTo.Logger(lc => lc + .Filter.ByExcluding(Matching.FromSource("Microsoft")) + .WriteTo.ApplicationInsights(services.GetService(), new CustomConverter(), LogEventLevel.Error)); + logs++; + LoggerHasBeenBuilt = true; }); hostBuilder.ConfigureLogging((context, logBuilder) => diff --git a/src/MigrationTools.Host/Services/DetectVersionService2.cs b/src/MigrationTools.Host/Services/DetectVersionService2.cs index b11300eb0..239f5173a 100644 --- a/src/MigrationTools.Host/Services/DetectVersionService2.cs +++ b/src/MigrationTools.Host/Services/DetectVersionService2.cs @@ -170,24 +170,29 @@ private WinGetPackage GetPackage() return _package; } - public static (Version version, string PreReleaseLabel, string versionString) GetRunningVersion() + public static (Version version, string PreReleaseLabel, string versionString) GetRunningVersion(IMigrationToolVersionInfo versionInfo = null) { - FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly()?.Location); - var matches = Regex.Matches(myFileVersionInfo.ProductVersion, @"^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-((? - => @"7acec2e" + => @"bfd206b" - => @"7acec2e6266f5f05b2807264ee8f1db7b94b1949" + => @"bfd206b3abbb82247f804cca802b4188e2f5c2d2" - => @"2024-07-25T18:26:18+01:00" + => @"2024-07-26T09:09:36+01:00" - => @"18" + => @"19" - => @"v15.1.5-Preview.2-18-g7acec2e" + => @"v15.1.5-Preview.2-19-gbfd206b" @@ -664,7 +664,7 @@ - => @"23" + => @"24" diff --git a/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs b/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs index c94010b5b..719353190 100644 --- a/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs +++ b/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs @@ -5,7 +5,6 @@ using MigrationTools.Services; using Serilog; using Serilog.Events; -using MigrationTools.Host.Tests.Services; namespace MigrationTools.Host.Services.Tests { @@ -33,28 +32,5 @@ public void DetectVersionServiceTest_Initialise() } - [TestMethod(), TestCategory("L0")] - public void GetRunningVersionTest_Release() - { - IMigrationToolVersionInfo versionInfo = new FakeMigrationToolVersionInfo("15.4.4", "15.4.4.0", "v15.4.4"); - var result = DetectVersionService2.GetRunningVersion(versionInfo); - Assert.AreEqual("15.4.4", result.versionString); - } - - [TestMethod(), TestCategory("L0")] - public void GetRunningVersionTest_Preview() - { - IMigrationToolVersionInfo versionInfo = new FakeMigrationToolVersionInfo("15.1.5-Preview.3", "15.1.5.3", "v15.1.5-Preview.3"); - var result = DetectVersionService2.GetRunningVersion(versionInfo); - Assert.AreEqual("15.1.5-Preview.3", result.versionString); - } - - [TestMethod(), TestCategory("L0")] - public void GetRunningVersionTest_Canary() - { - IMigrationToolVersionInfo versionInfo = new FakeMigrationToolVersionInfo("0.0.0-local+7acec2e6266f5f05b2807264ee8f1db7b94b1949", "0.0.0.0", "v15.1.5-Preview.2-18-g7acec2e"); - var result = DetectVersionService2.GetRunningVersion(versionInfo); - Assert.AreEqual("15.1.5-Local.2-18-g7acec2e", result.versionString); - } } } \ No newline at end of file diff --git a/src/MigrationTools.Host/Commands/CommandBase.cs b/src/MigrationTools.Host/Commands/CommandBase.cs index 29dfc42e3..0a45657a0 100644 --- a/src/MigrationTools.Host/Commands/CommandBase.cs +++ b/src/MigrationTools.Host/Commands/CommandBase.cs @@ -9,6 +9,7 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using MigrationTools.Host.Services; +using MigrationTools.Services; using Serilog; using Spectre.Console; using Spectre.Console.Cli; @@ -17,6 +18,7 @@ namespace MigrationTools.Host.Commands { internal abstract class CommandBase : AsyncCommand where TSettings : CommandSettingsBase { + private IMigrationToolVersion _MigrationToolVersion; private readonly IHostApplicationLifetime _LifeTime; private readonly IDetectOnlineService _detectOnlineService; private readonly IDetectVersionService2 _detectVersionService; @@ -24,8 +26,9 @@ internal abstract class CommandBase : AsyncCommand where T private readonly ITelemetryLogger _telemetryLogger; private static Stopwatch _mainTimer = new Stopwatch(); - public CommandBase(IHostApplicationLifetime appLifetime, IDetectOnlineService detectOnlineService, IDetectVersionService2 detectVersionService, ILogger> logger, ITelemetryLogger telemetryLogger) + public CommandBase(IHostApplicationLifetime appLifetime, IDetectOnlineService detectOnlineService, IDetectVersionService2 detectVersionService, ILogger> logger, ITelemetryLogger telemetryLogger, IMigrationToolVersion migrationToolVersion) { + _MigrationToolVersion = migrationToolVersion; _LifeTime = appLifetime; _detectOnlineService = detectOnlineService; _detectVersionService = detectVersionService; @@ -138,12 +141,12 @@ public void RunStartupLogic(TSettings settings) private void ApplicationStartup( TSettings settings) { _mainTimer.Start(); - AsciiLogo(DetectVersionService2.GetRunningVersion().versionString); + AsciiLogo(_MigrationToolVersion.GetRunningVersion().versionString); TelemetryNote(); _logger.LogInformation("Start Time: {StartTime}", DateTime.Now.ToUniversalTime().ToLocalTime()); _logger.LogInformation("Running with settings: {@settings}", settings); _logger.LogInformation("OSVersion: {OSVersion}", Environment.OSVersion.ToString()); - _logger.LogInformation("Version (Assembly): {Version}", DetectVersionService2.GetRunningVersion().versionString); + _logger.LogInformation("Version (Assembly): {Version}", _MigrationToolVersion.GetRunningVersion().versionString); } private void TelemetryNote() diff --git a/src/MigrationTools.Host/Commands/ExecuteMigrationCommand.cs b/src/MigrationTools.Host/Commands/ExecuteMigrationCommand.cs index 2ef1afa75..2f1fa0c64 100644 --- a/src/MigrationTools.Host/Commands/ExecuteMigrationCommand.cs +++ b/src/MigrationTools.Host/Commands/ExecuteMigrationCommand.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging; using MigrationTools.Host.Commands; using MigrationTools.Host.Services; +using MigrationTools.Services; using Spectre.Console.Cli; namespace MigrationTools.Host.Commands @@ -20,7 +21,7 @@ internal class ExecuteMigrationCommand : CommandBase logger, - IHostApplicationLifetime appLifetime, ITelemetryLogger telemetryLogger, IDetectOnlineService detectOnlineService, IDetectVersionService2 detectVersionService) : base(appLifetime, detectOnlineService, detectVersionService, logger, telemetryLogger) + IHostApplicationLifetime appLifetime, ITelemetryLogger telemetryLogger, IDetectOnlineService detectOnlineService, IDetectVersionService2 detectVersionService, IMigrationToolVersion migrationToolVersion) : base(appLifetime, detectOnlineService, detectVersionService, logger, telemetryLogger, migrationToolVersion) { Telemetery = telemetryLogger; _services = services; diff --git a/src/MigrationTools.Host/MigrationToolHost.cs b/src/MigrationTools.Host/MigrationToolHost.cs index 6f6f660f8..521d9daa9 100644 --- a/src/MigrationTools.Host/MigrationToolHost.cs +++ b/src/MigrationTools.Host/MigrationToolHost.cs @@ -24,6 +24,7 @@ using MigrationTools.Host.Commands; using System.Diagnostics; using System.Text.RegularExpressions; +using MigrationTools.Services; namespace MigrationTools.Host { @@ -38,12 +39,13 @@ public static class MigrationToolHost public static IHostBuilder CreateDefaultBuilder(string[] args) { var configFile = CommandSettingsBase.ForceGetConfigFile(args); + var mtv = new MigrationToolVersion(); var hostBuilder = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args); hostBuilder.UseSerilog((hostingContext, services, loggerConfiguration) => { - string outputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] [" + DetectVersionService2.GetRunningVersion().versionString + "] {Message:lj}{NewLine}{Exception}"; // {SourceContext} + string outputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] [" + mtv.GetRunningVersion().versionString + "] {Message:lj}{NewLine}{Exception}"; // {SourceContext} string logsPath = CreateLogsPath(); var logPath = Path.Combine(logsPath, $"migration-{logs}.log"); @@ -119,6 +121,8 @@ public static IHostBuilder CreateDefaultBuilder(string[] args) services.AddTransient(); //services.AddTransient(); services.AddTransient(); + services.AddSingleton(); + services.AddSingleton(); // Config services.AddSingleton(); diff --git a/src/MigrationTools.Host/Services/DetectVersionService2.cs b/src/MigrationTools.Host/Services/DetectVersionService2.cs index 239f5173a..0479ba637 100644 --- a/src/MigrationTools.Host/Services/DetectVersionService2.cs +++ b/src/MigrationTools.Host/Services/DetectVersionService2.cs @@ -9,6 +9,7 @@ using Microsoft.Extensions.Logging; using MigrationTools.DataContracts.Pipelines; using MigrationTools.EndpointEnrichers; +using MigrationTools.Services; using NuGet.Common; using NuGet.Configuration; using NuGet.Protocol; @@ -22,6 +23,7 @@ namespace MigrationTools.Host.Services { public class DetectVersionService2 : IDetectVersionService2 { + private IMigrationToolVersion _VerionsInfo; private readonly ITelemetryLogger _Telemetry; private ILogger _logger; @@ -45,7 +47,7 @@ public Version RunningVersion { get { - return GetRunningVersion().version; + return _VerionsInfo.GetRunningVersion().version; } } public Version AvailableVersion @@ -62,7 +64,7 @@ private Version GetAvailableVersion() { return Package.AvailableVersion; } - return new Version("0.0.0"); + return new Version("0.0.0"); } public Version InstalledVersion @@ -95,12 +97,13 @@ private bool GetIsPackageInstalled() return Package != null; } - public bool IsPackageManagerInstalled { + public bool IsPackageManagerInstalled + { get { return GetIsPackageManagerInstalled(); } - } + } private bool GetIsPackageManagerInstalled() { @@ -112,7 +115,7 @@ public bool IsPreviewVersion { get { - return !string.IsNullOrEmpty( GetRunningVersion().PreReleaseLabel); + return !string.IsNullOrEmpty(_VerionsInfo.GetRunningVersion().PreReleaseLabel); } } @@ -128,7 +131,7 @@ public bool IsRunningInDebug { get { - return GetRunningVersion().PreReleaseLabel.ToLower() == "local"; + return _VerionsInfo.GetRunningVersion().PreReleaseLabel.ToLower() == "local"; } } @@ -140,18 +143,20 @@ public bool IsNewLocalVersionAvailable } } - public DetectVersionService2(ITelemetryLogger telemetry, ILogger logger) + public DetectVersionService2(ITelemetryLogger telemetry, ILogger logger, IMigrationToolVersion verionsInfo) { + _VerionsInfo = verionsInfo; _Telemetry = telemetry; _logger = logger; if (IsPreviewVersion) { PackageId = "nkdAgility.AzureDevOpsMigrationTools.Preview"; - } else + } + else { PackageId = "nkdAgility.AzureDevOpsMigrationTools"; } - + } private WinGetPackage GetPackage() @@ -170,59 +175,32 @@ private WinGetPackage GetPackage() return _package; } - public static (Version version, string PreReleaseLabel, string versionString) GetRunningVersion(IMigrationToolVersionInfo versionInfo = null) + public class Benchmark : IDisposable { - if (versionInfo == null) - { - versionInfo = new MigrationToolVersionInfo(); - } - var matches = Regex.Matches(versionInfo.ProductVersion, @"^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-((? - => @"bfd206b" + => @"3b32325" - => @"bfd206b3abbb82247f804cca802b4188e2f5c2d2" + => @"3b32325b996b453ea0a9e7da89fcabee7bb5f7aa" - => @"2024-07-26T09:09:36+01:00" + => @"2024-07-26T11:42:33+01:00" - => @"19" + => @"20" - => @"v15.1.5-Preview.2-19-gbfd206b" + => @"v15.1.5-Preview.2-20-g3b32325" @@ -664,7 +664,7 @@ - => @"24" + => @"25" diff --git a/src/MigrationTools.Tests/Services/TelemetryClientAdapterTests.cs b/src/MigrationTools.Tests/Services/TelemetryClientAdapterTests.cs new file mode 100644 index 000000000..de23bdd04 --- /dev/null +++ b/src/MigrationTools.Tests/Services/TelemetryClientAdapterTests.cs @@ -0,0 +1,22 @@ +using Microsoft.ApplicationInsights; +using Microsoft.ApplicationInsights.Extensibility; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using MigrationTools; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MigrationTools.Tests +{ + [TestClass()] + public class TelemetryClientAdapterTests + { + [TestMethod()] + public void TrackExceptionTest() + { + TelemetryClientAdapter x = new TelemetryClientAdapter(null,); + } + } +} \ No newline at end of file diff --git a/src/MigrationTools/Services/MigrationToolVersionInfo.cs b/src/MigrationTools/Services/MigrationToolVersionInfo.cs index 455fa8cb9..b33197e99 100644 --- a/src/MigrationTools/Services/MigrationToolVersionInfo.cs +++ b/src/MigrationTools/Services/MigrationToolVersionInfo.cs @@ -58,29 +58,37 @@ public MigrationToolVersion(IMigrationToolVersionInfo migrationToolVersionInfo) public (Version version, string PreReleaseLabel, string versionString) GetRunningVersion() { - var matches = Regex.Matches(_MigrationToolVersionInfo.ProductVersion, @"^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-((? - => @"3b32325" + => @"061dcdc" - => @"3b32325b996b453ea0a9e7da89fcabee7bb5f7aa" + => @"061dcdc0b8ecf31f14ad6bdfab5d81892b8d6dff" - => @"2024-07-26T11:42:33+01:00" + => @"2024-07-26T12:01:47+01:00" - => @"20" + => @"21" - => @"v15.1.5-Preview.2-20-g3b32325" + => @"v15.1.5-Preview.2-21-g061dcdc" @@ -664,7 +664,7 @@ - => @"25" + => @"26" diff --git a/src/MigrationTools.Host/MigrationToolHost.cs b/src/MigrationTools.Host/MigrationToolHost.cs index 521d9daa9..8b19b442c 100644 --- a/src/MigrationTools.Host/MigrationToolHost.cs +++ b/src/MigrationTools.Host/MigrationToolHost.cs @@ -64,7 +64,7 @@ public static IHostBuilder CreateDefaultBuilder(string[] args) .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Debug, theme: AnsiConsoleTheme.Code, outputTemplate: outputTemplate)) .WriteTo.Logger(lc => lc .Filter.ByExcluding(Matching.FromSource("Microsoft")) - .WriteTo.ApplicationInsights(services.GetService(), new CustomConverter(), LogEventLevel.Error)); + .WriteTo.ApplicationInsights(services.GetService (), new CustomConverter(), LogEventLevel.Error)); logs++; LoggerHasBeenBuilt = true; }); diff --git a/src/MigrationTools.Tests/Services/TelemetryClientAdapterTests.cs b/src/MigrationTools.Tests/Services/TelemetryClientAdapterTests.cs index de23bdd04..49f6b432b 100644 --- a/src/MigrationTools.Tests/Services/TelemetryClientAdapterTests.cs +++ b/src/MigrationTools.Tests/Services/TelemetryClientAdapterTests.cs @@ -13,10 +13,6 @@ namespace MigrationTools.Tests [TestClass()] public class TelemetryClientAdapterTests { - [TestMethod()] - public void TrackExceptionTest() - { - TelemetryClientAdapter x = new TelemetryClientAdapter(null,); - } + } } \ No newline at end of file From 75860346e8fbb0fdb531030679b91c20dead7521 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Fri, 26 Jul 2024 13:35:22 +0100 Subject: [PATCH 09/14] =?UTF-8?q?Share=20Fakes=20across=20.tests:=20?= =?UTF-8?q?=E2=9C=A8=20(MigrationTools):=20add=20MigrationTools.Fakes=20pr?= =?UTF-8?q?oject=20for=20testing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new project, MigrationTools.Fakes, to provide fake implementations of IMigrationToolVersion and IMigrationToolVersionInfo for testing purposes. Update solution file and test projects to include references to the new MigrationTools.Fakes project. The addition of the MigrationTools.Fakes project allows for more robust and isolated unit tests by providing controlled, predictable versions of the IMigrationToolVersion and IMigrationToolVersionInfo interfaces. This improves the reliability and maintainability of the test suite. ✅ (tests): add project references to MigrationTools.Fakes and update tests Add references to `MigrationTools.Fakes` in various test projects to utilize fake implementations for testing purposes. Update `DetectVersionService2Tests` to use `FakeMigrationToolVersion`. Remove unused singleton services in `MigrationToolHost`. These changes improve the testability of the code by using fake implementations, making the tests more isolated and reliable. Removing unused services in `MigrationToolHost` cleans up the codebase and avoids potential confusion. --- MigrationTools.sln | 9 ++++++++- docs/Reference/Generated/MigrationTools.xml | 12 ++++++------ ...nTools.Clients.AzureDevops.Rest.Tests.csproj | 1 + .../ServiceProviderHelper.cs | 6 ++++++ ...MigrationTools.Clients.InMemory.Tests.csproj | 1 + .../ServiceProviderHelper.cs | 5 +++++ .../FakeMigrationToolVersion.cs | 12 ++++++++++++ .../FakeMigrationToolVersionInfo.cs | 10 ++++++++-- .../MigrationTools.Fakes.csproj | 17 +++++++++++++++++ .../MigrationTools.Host.Tests.csproj | 1 + .../Services/DetectVersionService2Tests.cs | 4 +++- src/MigrationTools.Host/MigrationToolHost.cs | 3 +-- .../MigrationTools.Integration.Tests.csproj | 1 + .../ServiceProviderHelper.cs | 5 +++++ .../MigrationTools.Tests.csproj | 1 + .../ServiceProviderHelper.cs | 5 +++++ .../Services/MigrationToolVersionInfoTests.cs | 1 + .../ServiceCollectionExtensions.cs | 3 +++ .../MigrationEngineTests.cs | 5 +++++ .../VstsSyncMigrator.Core.Tests.csproj | 1 + 20 files changed, 91 insertions(+), 12 deletions(-) create mode 100644 src/MigrationTools.Fakes/FakeMigrationToolVersion.cs rename src/{MigrationTools.Tests/Services => MigrationTools.Fakes}/FakeMigrationToolVersionInfo.cs (57%) create mode 100644 src/MigrationTools.Fakes/MigrationTools.Fakes.csproj diff --git a/MigrationTools.sln b/MigrationTools.sln index d0209cc7e..33b812fa8 100644 --- a/MigrationTools.sln +++ b/MigrationTools.sln @@ -126,7 +126,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{88C358 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{BB497233-248C-49DF-AE12-F7A76F775E74}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NKDAgility.AzureDevOps.Tools.CommandHost", "src\NKDAgility.AzureDevOps.Tools.CommandHost\NKDAgility.AzureDevOps.Tools.CommandHost.csproj", "{60EF98A1-5AA4-4589-8B6F-A77B3940025D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NKDAgility.AzureDevOps.Tools.CommandHost", "src\NKDAgility.AzureDevOps.Tools.CommandHost\NKDAgility.AzureDevOps.Tools.CommandHost.csproj", "{60EF98A1-5AA4-4589-8B6F-A77B3940025D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MigrationTools.Fakes", "src\MigrationTools.Fakes\MigrationTools.Fakes.csproj", "{EB20ED85-8876-4585-BC90-E6976C11DEE3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -214,6 +216,10 @@ Global {60EF98A1-5AA4-4589-8B6F-A77B3940025D}.Debug|Any CPU.Build.0 = Debug|Any CPU {60EF98A1-5AA4-4589-8B6F-A77B3940025D}.Release|Any CPU.ActiveCfg = Release|Any CPU {60EF98A1-5AA4-4589-8B6F-A77B3940025D}.Release|Any CPU.Build.0 = Release|Any CPU + {EB20ED85-8876-4585-BC90-E6976C11DEE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB20ED85-8876-4585-BC90-E6976C11DEE3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB20ED85-8876-4585-BC90-E6976C11DEE3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB20ED85-8876-4585-BC90-E6976C11DEE3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -248,6 +254,7 @@ Global {AC3B5101-83F5-4C28-976C-C325425D1988} = {1F5E9C8C-AD05-4C4F-B370-FF3D080A6541} {BB497233-248C-49DF-AE12-F7A76F775E74} = {83F36820-E9BC-4F48-8202-5EAF9530405E} {60EF98A1-5AA4-4589-8B6F-A77B3940025D} = {BB497233-248C-49DF-AE12-F7A76F775E74} + {EB20ED85-8876-4585-BC90-E6976C11DEE3} = {BB497233-248C-49DF-AE12-F7A76F775E74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {62EE0B27-C55A-46EE-8D17-1691DE9BBD50} diff --git a/docs/Reference/Generated/MigrationTools.xml b/docs/Reference/Generated/MigrationTools.xml index 436f06cb8..a0f2acfc7 100644 --- a/docs/Reference/Generated/MigrationTools.xml +++ b/docs/Reference/Generated/MigrationTools.xml @@ -609,27 +609,27 @@ - => @"061dcdc" + => @"ea0ffa0" - => @"061dcdc0b8ecf31f14ad6bdfab5d81892b8d6dff" + => @"ea0ffa07c0c5bc3b22543d0e60aa83aa6f02cdb3" - => @"2024-07-26T12:01:47+01:00" + => @"2024-07-26T12:48:41+01:00" - => @"21" + => @"22" - => @"v15.1.5-Preview.2-21-g061dcdc" + => @"v15.1.5-Preview.2-22-gea0ffa0" @@ -664,7 +664,7 @@ - => @"26" + => @"27" diff --git a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj index 1fa84dae1..6f9d73233 100644 --- a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj +++ b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj @@ -19,6 +19,7 @@ + diff --git a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/ServiceProviderHelper.cs index 12fc32133..0ffb0b124 100644 --- a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/ServiceProviderHelper.cs @@ -1,6 +1,8 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using MigrationTools.Endpoints; +using MigrationTools.Fakes; +using MigrationTools.Services; using MigrationTools.TestExtensions; namespace MigrationTools.Tests @@ -15,9 +17,13 @@ internal static ServiceProvider GetServices() services.AddMigrationToolServices(); services.AddMigrationToolServicesForClientAzureDevopsRest(configuration); + AddEndpoint(services, "Source", "migrationSource1"); AddEndpoint(services, "Target", "migrationTarget1"); + services.AddSingleton(); + services.AddSingleton(); + return services.BuildServiceProvider(); } diff --git a/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj b/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj index 51b90f725..2f833e8b7 100644 --- a/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj +++ b/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj @@ -22,6 +22,7 @@ + diff --git a/src/MigrationTools.Clients.InMemory.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Clients.InMemory.Tests/ServiceProviderHelper.cs index 651ce61ab..418b09d02 100644 --- a/src/MigrationTools.Clients.InMemory.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Clients.InMemory.Tests/ServiceProviderHelper.cs @@ -1,4 +1,6 @@ using Microsoft.Extensions.DependencyInjection; +using MigrationTools.Fakes; +using MigrationTools.Services; using MigrationTools.TestExtensions; namespace MigrationTools.Tests @@ -13,6 +15,9 @@ internal static ServiceProvider GetServices() services.AddMigrationToolServices(); services.AddMigrationToolServicesForClientInMemory(); + services.AddSingleton(); + services.AddSingleton(); + return services.BuildServiceProvider(); } } diff --git a/src/MigrationTools.Fakes/FakeMigrationToolVersion.cs b/src/MigrationTools.Fakes/FakeMigrationToolVersion.cs new file mode 100644 index 000000000..dabe9cd68 --- /dev/null +++ b/src/MigrationTools.Fakes/FakeMigrationToolVersion.cs @@ -0,0 +1,12 @@ +using MigrationTools.Services; + +namespace MigrationTools.Fakes +{ + public class FakeMigrationToolVersion : IMigrationToolVersion + { + public (Version version, string PreReleaseLabel, string versionString) GetRunningVersion() + { + return (new System.Version("0.0.0"), "test", "0.0.0-test"); + } + } +} \ No newline at end of file diff --git a/src/MigrationTools.Tests/Services/FakeMigrationToolVersionInfo.cs b/src/MigrationTools.Fakes/FakeMigrationToolVersionInfo.cs similarity index 57% rename from src/MigrationTools.Tests/Services/FakeMigrationToolVersionInfo.cs rename to src/MigrationTools.Fakes/FakeMigrationToolVersionInfo.cs index 328b43ad9..f20f8cdfb 100644 --- a/src/MigrationTools.Tests/Services/FakeMigrationToolVersionInfo.cs +++ b/src/MigrationTools.Fakes/FakeMigrationToolVersionInfo.cs @@ -7,10 +7,16 @@ using System.Threading.Tasks; using MigrationTools.Services; -namespace MigrationTools.Tests +namespace MigrationTools.Fakes { - class FakeMigrationToolVersionInfo : MigrationToolVersionInfo + public class FakeMigrationToolVersionInfo : MigrationToolVersionInfo { + public FakeMigrationToolVersionInfo() + { + ProductVersion = "0.0.0-test+7acec2e6266f5f05b2807264ee8f1db7b94b1949"; + FileVersion = "0.0.0.0"; + GitTag = "v0.0.0-test.0-0-g7acec2e"; + } public FakeMigrationToolVersionInfo(string productVersion, string fileVersion, string gitTag) { ProductVersion = productVersion; diff --git a/src/MigrationTools.Fakes/MigrationTools.Fakes.csproj b/src/MigrationTools.Fakes/MigrationTools.Fakes.csproj new file mode 100644 index 000000000..4bb328964 --- /dev/null +++ b/src/MigrationTools.Fakes/MigrationTools.Fakes.csproj @@ -0,0 +1,17 @@ + + + + netstandard2.0;net8.0 + enable + enable + + + + + + + + + + + diff --git a/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj b/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj index 757a1e4c5..c70cc31c0 100644 --- a/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj +++ b/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj @@ -26,6 +26,7 @@ + diff --git a/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs b/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs index 719353190..f5954ec6f 100644 --- a/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs +++ b/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs @@ -5,6 +5,8 @@ using MigrationTools.Services; using Serilog; using Serilog.Events; +using MigrationTools.Host.Tests; +using MigrationTools.Tests; namespace MigrationTools.Host.Services.Tests { @@ -27,7 +29,7 @@ public void Setup() public void DetectVersionServiceTest_Initialise() { var loggerFactory = new LoggerFactory().AddSerilog(); - IDetectVersionService2 dos = new DetectVersionService2(new TelemetryLoggerMock(), new Logger(loggerFactory)); + IDetectVersionService2 dos = new DetectVersionService2(new TelemetryLoggerMock(), new Logger(loggerFactory), new FakeMigrationToolVersion()); Assert.IsNotNull(dos); } diff --git a/src/MigrationTools.Host/MigrationToolHost.cs b/src/MigrationTools.Host/MigrationToolHost.cs index 8b19b442c..18c153bed 100644 --- a/src/MigrationTools.Host/MigrationToolHost.cs +++ b/src/MigrationTools.Host/MigrationToolHost.cs @@ -121,8 +121,7 @@ public static IHostBuilder CreateDefaultBuilder(string[] args) services.AddTransient(); //services.AddTransient(); services.AddTransient(); - services.AddSingleton(); - services.AddSingleton(); + // Config services.AddSingleton(); diff --git a/src/MigrationTools.Integration.Tests/MigrationTools.Integration.Tests.csproj b/src/MigrationTools.Integration.Tests/MigrationTools.Integration.Tests.csproj index 6dd6dca23..adc8f8cda 100644 --- a/src/MigrationTools.Integration.Tests/MigrationTools.Integration.Tests.csproj +++ b/src/MigrationTools.Integration.Tests/MigrationTools.Integration.Tests.csproj @@ -28,6 +28,7 @@ + diff --git a/src/MigrationTools.Integration.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Integration.Tests/ServiceProviderHelper.cs index ee10e7136..7befa5ede 100644 --- a/src/MigrationTools.Integration.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Integration.Tests/ServiceProviderHelper.cs @@ -2,6 +2,8 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using MigrationTools.Endpoints; +using MigrationTools.Fakes; +using MigrationTools.Services; using MigrationTools.TestExtensions; namespace MigrationTools.Tests @@ -24,6 +26,9 @@ internal static ServiceProvider GetServicesV2() AddEndpoint(services, "Source", "migrationSource1"); AddEndpoint(services, "Target", "migrationTarget1"); + services.AddSingleton(); + services.AddSingleton(); + return services.BuildServiceProvider(); } diff --git a/src/MigrationTools.Tests/MigrationTools.Tests.csproj b/src/MigrationTools.Tests/MigrationTools.Tests.csproj index 2d71c7fc5..1a5dfb9af 100644 --- a/src/MigrationTools.Tests/MigrationTools.Tests.csproj +++ b/src/MigrationTools.Tests/MigrationTools.Tests.csproj @@ -21,6 +21,7 @@ + diff --git a/src/MigrationTools.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Tests/ServiceProviderHelper.cs index c211260bf..f68cccba7 100644 --- a/src/MigrationTools.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Tests/ServiceProviderHelper.cs @@ -3,8 +3,10 @@ using MigrationTools.EndpointEnrichers; using MigrationTools.Endpoints; using MigrationTools.Enrichers; +using MigrationTools.Fakes; using MigrationTools.ProcessorEnrichers.WorkItemProcessorEnrichers; using MigrationTools.Processors; +using MigrationTools.Services; using MigrationTools.TestExtensions; namespace MigrationTools.Tests @@ -39,6 +41,9 @@ internal static ServiceProvider GetWorkItemMigrationProcessor() AddEndpoint(services, "Source"); AddEndpoint(services, "Target"); + services.AddSingleton(); + services.AddSingleton(); + return services.BuildServiceProvider(); } diff --git a/src/MigrationTools.Tests/Services/MigrationToolVersionInfoTests.cs b/src/MigrationTools.Tests/Services/MigrationToolVersionInfoTests.cs index a93075564..f14d58c12 100644 --- a/src/MigrationTools.Tests/Services/MigrationToolVersionInfoTests.cs +++ b/src/MigrationTools.Tests/Services/MigrationToolVersionInfoTests.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using MigrationTools.Fakes; namespace MigrationTools.Tests { diff --git a/src/MigrationTools/ServiceCollectionExtensions.cs b/src/MigrationTools/ServiceCollectionExtensions.cs index fc74439bf..e650d174f 100644 --- a/src/MigrationTools/ServiceCollectionExtensions.cs +++ b/src/MigrationTools/ServiceCollectionExtensions.cs @@ -6,6 +6,7 @@ using MigrationTools.Enrichers; using MigrationTools.ProcessorEnrichers.WorkItemProcessorEnrichers; using MigrationTools.Processors; +using MigrationTools.Services; namespace MigrationTools { @@ -32,6 +33,8 @@ public static void AddMigrationToolServices(this IServiceCollection context) //context.AddTransient(); // processor Enrichers context.AddTransient(); + + } [Obsolete("This is the v1 Archtiecture, we are movign to V2", false)] diff --git a/src/VstsSyncMigrator.Core.Tests/MigrationEngineTests.cs b/src/VstsSyncMigrator.Core.Tests/MigrationEngineTests.cs index 9b6e76fd7..bbc4217e2 100644 --- a/src/VstsSyncMigrator.Core.Tests/MigrationEngineTests.cs +++ b/src/VstsSyncMigrator.Core.Tests/MigrationEngineTests.cs @@ -8,6 +8,8 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using MigrationTools; using MigrationTools._EngineV1.Configuration; +using MigrationTools.Fakes; +using MigrationTools.Services; using MigrationTools.TestExtensions; using Serilog; @@ -40,6 +42,9 @@ public void Setup() services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + _services = services.BuildServiceProvider(); } diff --git a/src/VstsSyncMigrator.Core.Tests/VstsSyncMigrator.Core.Tests.csproj b/src/VstsSyncMigrator.Core.Tests/VstsSyncMigrator.Core.Tests.csproj index d32f05042..53f5696dd 100644 --- a/src/VstsSyncMigrator.Core.Tests/VstsSyncMigrator.Core.Tests.csproj +++ b/src/VstsSyncMigrator.Core.Tests/VstsSyncMigrator.Core.Tests.csproj @@ -22,6 +22,7 @@ + From 9b4dfe0a5716b152c6c5382f37979ec30f2292d9 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Fri, 26 Jul 2024 13:58:26 +0100 Subject: [PATCH 10/14] =?UTF-8?q?Share=20Fakes=20across=20.tests:=20?= =?UTF-8?q?=E2=9C=85=20(DetectVersionService2Tests.cs):=20add=20MigrationT?= =?UTF-8?q?ools.Fakes=20import=20to=20test=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The import of `MigrationTools.Fakes` is added to the test file to include necessary fake implementations for testing purposes. This ensures that the tests can run with mock data and dependencies, improving test reliability and coverage. --- .../Services/DetectVersionService2Tests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs b/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs index f5954ec6f..dacdd87dc 100644 --- a/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs +++ b/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs @@ -7,6 +7,7 @@ using Serilog.Events; using MigrationTools.Host.Tests; using MigrationTools.Tests; +using MigrationTools.Fakes; namespace MigrationTools.Host.Services.Tests { From e600c81e632a4a16b0bd4a017e69a17c7789096f Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Fri, 26 Jul 2024 14:14:25 +0100 Subject: [PATCH 11/14] =?UTF-8?q?=F0=9F=93=9D=20(docs):=20update=20Migrati?= =?UTF-8?q?onTools.xml=20with=20new=20commit=20details=20=E2=99=BB?= =?UTF-8?q?=EF=B8=8F=20(tests):=20remove=20redundant=20TestCategory=20attr?= =?UTF-8?q?ibute=20from=20test=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MigrationTools.xml file is updated to reflect the latest commit details, ensuring the documentation is current. The redundant "AzureDevOps.ObjectModel" TestCategory attributes are removed from various test methods to streamline the test annotations and reduce unnecessary repetition. 🐛 (TfsMigrationClient): fix log message formatting for error handling ♻️ (Tests): remove redundant test categories for clarity 🔧 (EngineConfigurationBuilder): change log level to critical for version mismatch The log message in TfsMigrationClient is reformatted to include the exception message directly, improving readability. Redundant test categories are removed from various test methods to streamline the test suite and avoid unnecessary categorization. The log level in EngineConfigurationBuilder is changed to critical for configuration version mismatches to better reflect the severity of the issue. --- docs/Reference/Generated/MigrationTools.xml | 12 ++++++------ .../Endpoints/TfsWorkItemEndPointTests.cs | 8 ++++---- .../TfsNodeStructureTests.cs | 2 +- .../TfsRevisionManagerTests.cs | 18 +++++++++--------- .../Processors/TfsSharedQueryProcessorTests.cs | 8 ++++---- .../TfsTeamSettingsProcessorTests.cs | 8 ++++---- .../_Enginev1/Clients/TfsMigrationClient.cs | 2 +- .../AzureDevOpsPipelineProcessorTests.cs | 12 ++++++------ .../MigrationHostTests.cs | 8 ++++---- .../AzureDevOpsObjectModelTests.cs | 2 +- .../StringManipulatorEnricherTests.cs | 8 ++++---- .../WorkItemMigrationProcessorTests.cs | 4 ++-- .../EngineConfigurationBuilder.cs | 2 +- 13 files changed, 47 insertions(+), 47 deletions(-) diff --git a/docs/Reference/Generated/MigrationTools.xml b/docs/Reference/Generated/MigrationTools.xml index a0f2acfc7..7803ce90d 100644 --- a/docs/Reference/Generated/MigrationTools.xml +++ b/docs/Reference/Generated/MigrationTools.xml @@ -609,27 +609,27 @@ - => @"ea0ffa0" + => @"9b4dfe0" - => @"ea0ffa07c0c5bc3b22543d0e60aa83aa6f02cdb3" + => @"9b4dfe0a5716b152c6c5382f37979ec30f2292d9" - => @"2024-07-26T12:48:41+01:00" + => @"2024-07-26T13:58:26+01:00" - => @"22" + => @"24" - => @"v15.1.5-Preview.2-22-gea0ffa0" + => @"v15.1.5-Preview.2-24-g9b4dfe0" @@ -664,7 +664,7 @@ - => @"27" + => @"29" diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Endpoints/TfsWorkItemEndPointTests.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Endpoints/TfsWorkItemEndPointTests.cs index 63b4712bd..4561ea89c 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Endpoints/TfsWorkItemEndPointTests.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Endpoints/TfsWorkItemEndPointTests.cs @@ -19,7 +19,7 @@ public void Setup() Services = ServiceProviderHelper.GetServices(); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L3")] public void TfsWorkItemEndPointTest() { var endpoint = Services.GetRequiredService(); @@ -28,7 +28,7 @@ public void TfsWorkItemEndPointTest() Assert.IsNotNull(endpoint); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L3")] public void TfsWorkItemEndPointConfigureTest() { var endpoint = Services.GetRequiredService(); @@ -36,7 +36,7 @@ public void TfsWorkItemEndPointConfigureTest() Assert.IsNotNull(endpoint); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L3")] public void TfsWorkItemEndPointGetWorkItemsTest() { var endpoint = Services.GetRequiredService(); @@ -45,7 +45,7 @@ public void TfsWorkItemEndPointGetWorkItemsTest() Assert.AreEqual(13, result.Count()); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L3")] public void TfsWorkItemEndPointGetWorkItemsQueryTest() { TfsWorkItemEndpoint endpoint = Services.GetRequiredService(); diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsNodeStructureTests.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsNodeStructureTests.cs index 8ef065246..80fb971c4 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsNodeStructureTests.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsNodeStructureTests.cs @@ -37,7 +37,7 @@ public void Setup() }); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void GetTfsNodeStructure_WithDifferentAreaPath() { var nodeStructure = _services.GetRequiredService(); diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsRevisionManagerTests.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsRevisionManagerTests.cs index a31a86569..83ebad318 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsRevisionManagerTests.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsRevisionManagerTests.cs @@ -45,7 +45,7 @@ private static List GetWorkItemWithRevisions(DateTime currentDateT } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerInSync1() { var peOptions = GetTfsRevisionManagerOptions(); @@ -62,7 +62,7 @@ public void TfsRevisionManagerInSync1() } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerInSync10() { var peOptions = GetTfsRevisionManagerOptions(); @@ -79,7 +79,7 @@ public void TfsRevisionManagerInSync10() } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerSync1() { var peOptions = GetTfsRevisionManagerOptions(); @@ -95,7 +95,7 @@ public void TfsRevisionManagerSync1() Assert.AreEqual(1, revs.Count); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerSync10() { var peOptions = GetTfsRevisionManagerOptions(); @@ -111,7 +111,7 @@ public void TfsRevisionManagerSync10() Assert.AreEqual(10, revs.Count); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerReplayRevisionsOff() { var peOptions = GetTfsRevisionManagerOptions(); @@ -129,7 +129,7 @@ public void TfsRevisionManagerReplayRevisionsOff() } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerMaxRevision51() { var peOptions = GetTfsRevisionManagerOptions(); @@ -146,7 +146,7 @@ public void TfsRevisionManagerMaxRevision51() Assert.AreEqual(0, revs.Count); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerMaxRevision56() { var peOptions = GetTfsRevisionManagerOptions(); @@ -163,7 +163,7 @@ public void TfsRevisionManagerMaxRevision56() Assert.AreEqual(5, revs.Count); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerMaxRevision59() { var peOptions = GetTfsRevisionManagerOptions(); @@ -179,7 +179,7 @@ public void TfsRevisionManagerMaxRevision59() Assert.AreEqual(5, revs.Count); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerDatesMustBeIncreasing() { var peOptions = GetTfsRevisionManagerOptions(); diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsSharedQueryProcessorTests.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsSharedQueryProcessorTests.cs index 176dc3f9b..2ce4cbd15 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsSharedQueryProcessorTests.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsSharedQueryProcessorTests.cs @@ -9,14 +9,14 @@ namespace MigrationTools.Processors.Tests [TestClass()] public class TfsSharedQueryProcessorTests : TfsProcessorTests { - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsSharedQueryProcessorTest() { var x = Services.GetRequiredService(); Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsSharedQueryProcessorConfigureTest() { var y = new TfsSharedQueryProcessorOptions @@ -31,7 +31,7 @@ public void TfsSharedQueryProcessorConfigureTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsSharedQueryProcessorRunTest() { var y = new TfsSharedQueryProcessorOptions @@ -46,7 +46,7 @@ public void TfsSharedQueryProcessorRunTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L3")] public void TfsSharedQueryProcessorNoEnrichersTest() { // Senario 1 Migration from Tfs to Tfs with no Enrichers. diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsTeamSettingsProcessorTests.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsTeamSettingsProcessorTests.cs index d9a86b241..3a8ddb8e8 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsTeamSettingsProcessorTests.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsTeamSettingsProcessorTests.cs @@ -6,14 +6,14 @@ namespace MigrationTools.Processors.Tests [TestClass()] public class TfsTeamSettingsProcessorTests : TfsProcessorTests { - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsTeamSettingsProcessorTest() { var x = Services.GetRequiredService(); Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsTeamSettingsProcessorConfigureTest() { var y = new TfsTeamSettingsProcessorOptions @@ -30,7 +30,7 @@ public void TfsTeamSettingsProcessorConfigureTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsTeamSettingsProcessorRunTest() { var y = new TfsTeamSettingsProcessorOptions @@ -47,7 +47,7 @@ public void TfsTeamSettingsProcessorRunTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L3")] public void TfsTeamSettingsProcessorNoEnrichersTest() { // Senario 1 Migration from Tfs to Tfs with no Enrichers. diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel/_Enginev1/Clients/TfsMigrationClient.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel/_Enginev1/Clients/TfsMigrationClient.cs index 91afb77c1..1199b65a5 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel/_Enginev1/Clients/TfsMigrationClient.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel/_Enginev1/Clients/TfsMigrationClient.cs @@ -175,7 +175,7 @@ private TfsTeamProjectCollection GetDependantTfsCollection(NetworkCredential cre new Dictionary { { "Time",timer.ElapsedMilliseconds } }); - Log.Error(ex, "Unable to configure store: Check persmissions and credentials for {AuthenticationMode}!", _config.AuthenticationMode); + Log.Error("Unable to configure store: Check persmissions and credentials for {AuthenticationMode}: " + ex.Message, _config.AuthenticationMode); switch (_config.AuthenticationMode) { case AuthenticationMode.AccessToken: diff --git a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/Processors/AzureDevOpsPipelineProcessorTests.cs b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/Processors/AzureDevOpsPipelineProcessorTests.cs index 9a26eb8f1..b9c28cd75 100644 --- a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/Processors/AzureDevOpsPipelineProcessorTests.cs +++ b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/Processors/AzureDevOpsPipelineProcessorTests.cs @@ -11,14 +11,14 @@ namespace MigrationTools.Processors.Tests [TestClass()] public class AzureDevOpsPipelineProcessorTests : AzureDevOpsProcessorTests { - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.REST")] + [TestMethod(), TestCategory("L0")] public void AzureDevOpsPipelineProcessorTest() { var x = Services.GetRequiredService(); Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.REST")] + [TestMethod(), TestCategory("L0")] public void AzureDevOpsPipelineProcessorConfigureTest() { var y = new AzureDevOpsPipelineProcessorOptions @@ -32,7 +32,7 @@ public void AzureDevOpsPipelineProcessorConfigureTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.REST")] + [TestMethod(), TestCategory("L0")] public void AzureDevOpsPipelineProcessorRunTest() { var y = new AzureDevOpsPipelineProcessorOptions @@ -46,7 +46,7 @@ public void AzureDevOpsPipelineProcessorRunTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.REST")] + [TestMethod(), TestCategory("L3")] public void AzureDevOpsPipelineProcessorNoEnrichersTest() { // Senario 1 Migration from Tfs to Tfs with no Enrichers. @@ -57,7 +57,7 @@ public void AzureDevOpsPipelineProcessorNoEnrichersTest() Assert.AreEqual(ProcessingStatus.Complete, processor.Status); } - [TestMethod, TestCategory("L3"), TestCategory("AzureDevOps.REST")] + [TestMethod, TestCategory("L3")] public void AzureDevOpsPipelineProcessorSelectedBuildDefinitionsTest() { var config = new AzureDevOpsPipelineProcessorOptions @@ -89,7 +89,7 @@ public void AzureDevOpsPipelineProcessorSelectedBuildDefinitionsTest() Assert.AreEqual(2, InMemorySink.Instance.LogEvents.Count(configuredMessageFilter)); } - [TestMethod, TestCategory("L3"), TestCategory("AzureDevOps.REST")] + [TestMethod, TestCategory("L3")] public void AzureDevOpsPipelineProcessorSelectedReleaseDefinitionsTest() { var config = new AzureDevOpsPipelineProcessorOptions diff --git a/src/MigrationTools.Host.Tests/MigrationHostTests.cs b/src/MigrationTools.Host.Tests/MigrationHostTests.cs index bb97d24d6..541513ccd 100644 --- a/src/MigrationTools.Host.Tests/MigrationHostTests.cs +++ b/src/MigrationTools.Host.Tests/MigrationHostTests.cs @@ -16,14 +16,14 @@ public void Setup() host = MigrationToolHost.CreateDefaultBuilder(new string[] { "execute", "-c", "configuration.json" }).Build(); } - [TestMethod, TestCategory("L2"), TestCategory("Host")] + [TestMethod, TestCategory("L2")] [Ignore("need to ignore for now, missing a good config file for non-objectmodel")] public void MigrationHostTest() { IMigrationEngine mh = host.Services.GetRequiredService(); } - [TestMethod, TestCategory("L1"), TestCategory("Host")] + [TestMethod, TestCategory("L1")] [Ignore("need to ignore for now, untill we get some generic field maps")] public void TestEngineExecuteEmptyProcessors() { @@ -33,7 +33,7 @@ public void TestEngineExecuteEmptyProcessors() me.Run(); } - [TestMethod, TestCategory("L1"), TestCategory("Host")] + [TestMethod, TestCategory("L1")] [Ignore("need to ignore for now, missing a good config file for non-objectmodel")] public void TestEngineExecuteEmptyFieldMaps() { @@ -44,7 +44,7 @@ public void TestEngineExecuteEmptyFieldMaps() me.Run(); } - [TestMethod, TestCategory("L3"), TestCategory("L2"), TestCategory("Host")] + [TestMethod, TestCategory("L3"), TestCategory("L2")] [Ignore("need to ignore for now, missing a good config file for non-objectmodel")] public void TestEngineExecuteProcessors() { diff --git a/src/MigrationTools.Integration.Tests/AzureDevOpsObjectModelTests.cs b/src/MigrationTools.Integration.Tests/AzureDevOpsObjectModelTests.cs index 7b9a5ced8..8e50b4be4 100644 --- a/src/MigrationTools.Integration.Tests/AzureDevOpsObjectModelTests.cs +++ b/src/MigrationTools.Integration.Tests/AzureDevOpsObjectModelTests.cs @@ -24,7 +24,7 @@ public void Setup() Log.Logger.Information("Logger is initialized"); } - [TestMethod(), TestCategory("L3"), TestCategory("Integration")] + [TestMethod(), TestCategory("L3")] public void TestTfsToTfsNoEnrichers() { // Senario 1 Migration from Tfs to Tfs with no Enrichers. diff --git a/src/MigrationTools.Tests/ProcessorEnrichers/StringManipulatorEnricherTests.cs b/src/MigrationTools.Tests/ProcessorEnrichers/StringManipulatorEnricherTests.cs index 244c0c18d..fb89ac796 100644 --- a/src/MigrationTools.Tests/ProcessorEnrichers/StringManipulatorEnricherTests.cs +++ b/src/MigrationTools.Tests/ProcessorEnrichers/StringManipulatorEnricherTests.cs @@ -21,7 +21,7 @@ public void Setup() Services = ServiceProviderHelper.GetWorkItemMigrationProcessor(); } - [TestMethod(), TestCategory("L0"), TestCategory("Generic.Processor")] + [TestMethod(), TestCategory("L0")] public void StringManipulatorEnricher_ConfigureTest() { var y = new StringManipulatorEnricherOptions @@ -45,7 +45,7 @@ public void StringManipulatorEnricher_ConfigureTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L1"), TestCategory("ProcessorEnrichers")] + [TestMethod(), TestCategory("L1")] public void StringManipulatorEnricher_RegexTest() { var y = new StringManipulatorEnricherOptions @@ -82,7 +82,7 @@ public void StringManipulatorEnricher_RegexTest() Assert.AreEqual("Test 2", fieldItem.Value); } - [TestMethod(), TestCategory("L1"), TestCategory("ProcessorEnrichers")] + [TestMethod(), TestCategory("L1")] public void StringManipulatorEnricher_LengthShorterThanMaxTest() { var y = new StringManipulatorEnricherOptions @@ -108,7 +108,7 @@ public void StringManipulatorEnricher_LengthShorterThanMaxTest() Assert.AreEqual(4, fieldItem.Value.ToString().Length); } - [TestMethod(), TestCategory("L1"), TestCategory("ProcessorEnrichers")] + [TestMethod(), TestCategory("L1")] public void StringManipulatorEnricher_LengthLongerThanMaxTest() { var y = new StringManipulatorEnricherOptions diff --git a/src/MigrationTools.Tests/Processors/WorkItemMigrationProcessorTests.cs b/src/MigrationTools.Tests/Processors/WorkItemMigrationProcessorTests.cs index 3d5d4a397..b6f805924 100644 --- a/src/MigrationTools.Tests/Processors/WorkItemMigrationProcessorTests.cs +++ b/src/MigrationTools.Tests/Processors/WorkItemMigrationProcessorTests.cs @@ -16,7 +16,7 @@ public void Setup() Services = ServiceProviderHelper.GetWorkItemMigrationProcessor(); } - [TestMethod(), TestCategory("L0"), TestCategory("Generic.Processor")] + [TestMethod(), TestCategory("L0")] public void WorkItemMigrationProcessorConfigureTest() { var y = new WorkItemTrackingProcessorOptions @@ -33,7 +33,7 @@ public void WorkItemMigrationProcessorConfigureTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L1"), TestCategory("Generic.Processor")] + [TestMethod(), TestCategory("L1")] public void WorkItemMigrationProcessorRunTest() { var y = new WorkItemTrackingProcessorOptions diff --git a/src/MigrationTools/_EngineV1/Configuration/EngineConfigurationBuilder.cs b/src/MigrationTools/_EngineV1/Configuration/EngineConfigurationBuilder.cs index 49f0eeb94..f1e8aebfc 100644 --- a/src/MigrationTools/_EngineV1/Configuration/EngineConfigurationBuilder.cs +++ b/src/MigrationTools/_EngineV1/Configuration/EngineConfigurationBuilder.cs @@ -73,7 +73,7 @@ public EngineConfiguration BuildFromFile(string configFile = "configuration.json string appVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(2); if (ec?.Version != appVersion) { - _logger.LogError("The config version {Version} does not match the current app version {appVersion}. There may be compatability issues and we recommend that you generate a new default config and then tranfer the settings accross.", ec.Version, appVersion); + _logger.LogCritical("The config version {Version} does not match the current app version {appVersion}. There may be compatability issues and we recommend that you generate a new default config and then tranfer the settings accross.", ec.Version, appVersion); if (System.Diagnostics.Debugger.IsAttached) { _logger.LogInformation("But since you're running in Debug, let's move on"); From 0e5f65ff4368b8da72e7e64991c4d0a095637a02 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Fri, 26 Jul 2024 14:20:01 +0100 Subject: [PATCH 12/14] =?UTF-8?q?=E2=9C=85=20(tests):=20update=20project?= =?UTF-8?q?=20references=20and=20add=20new=20test=20helpers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rename `MigrationTools.Fakes` project to `MigrationTools.Helpers.Tests` - Add `MigrationTools.Helpers.Tests` project references to various test projects - Include new fake services in `ServiceProviderHelper` for better test coverage The changes improve the organization and clarity of test projects by renaming the `MigrationTools.Fakes` project to `MigrationTools.Helpers.Tests`. This better reflects its purpose. Additionally, adding the new project references and fake services enhances test coverage and modularity, making it easier to manage and extend tests. --- MigrationTools.sln | 2 +- ...grationTools.Clients.AzureDevops.ObjectModel.Tests.csproj | 1 + .../ServiceProviderHelper.cs | 5 +++++ .../MigrationTools.Clients.FileSystem.Tests.csproj | 1 + .../ServiceProviderHelper.cs | 5 +++++ ...ools.Fakes.csproj => MigrationTools.Helpers.Tests.csproj} | 0 .../MigrationTools.Integration.Tests.csproj | 1 + .../VstsSyncMigrator.Core.Tests.csproj | 2 +- 8 files changed, 15 insertions(+), 2 deletions(-) rename src/MigrationTools.Fakes/{MigrationTools.Fakes.csproj => MigrationTools.Helpers.Tests.csproj} (100%) diff --git a/MigrationTools.sln b/MigrationTools.sln index 33b812fa8..1d248ae92 100644 --- a/MigrationTools.sln +++ b/MigrationTools.sln @@ -128,7 +128,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{BB4972 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NKDAgility.AzureDevOps.Tools.CommandHost", "src\NKDAgility.AzureDevOps.Tools.CommandHost\NKDAgility.AzureDevOps.Tools.CommandHost.csproj", "{60EF98A1-5AA4-4589-8B6F-A77B3940025D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MigrationTools.Fakes", "src\MigrationTools.Fakes\MigrationTools.Fakes.csproj", "{EB20ED85-8876-4585-BC90-E6976C11DEE3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MigrationTools.Helpers.Tests", "src\MigrationTools.Fakes\MigrationTools.Helpers.Tests.csproj", "{EB20ED85-8876-4585-BC90-E6976C11DEE3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/MigrationTools.Clients.AzureDevops.ObjectModel.Tests.csproj b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/MigrationTools.Clients.AzureDevops.ObjectModel.Tests.csproj index 5d9ce7e47..de4d64e22 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/MigrationTools.Clients.AzureDevops.ObjectModel.Tests.csproj +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/MigrationTools.Clients.AzureDevops.ObjectModel.Tests.csproj @@ -27,6 +27,7 @@ + diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ServiceProviderHelper.cs index 19ab26968..2375fa7a2 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ServiceProviderHelper.cs @@ -1,6 +1,8 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using MigrationTools.Endpoints; +using MigrationTools.Fakes; +using MigrationTools.Services; using MigrationTools.TestExtensions; namespace MigrationTools.Tests @@ -23,6 +25,9 @@ public static ServiceProvider GetServices() AddTfsTeamEndpoint(services, "TfsTeamSettingsSource", "migrationSource1"); AddTfsTeamEndpoint(services, "TfsTeamSettingsTarget", "migrationTarget1"); + services.AddSingleton(); + services.AddSingleton(); + return services.BuildServiceProvider(); } diff --git a/src/MigrationTools.Clients.FileSystem.Tests/MigrationTools.Clients.FileSystem.Tests.csproj b/src/MigrationTools.Clients.FileSystem.Tests/MigrationTools.Clients.FileSystem.Tests.csproj index 4558dd485..79ad15394 100644 --- a/src/MigrationTools.Clients.FileSystem.Tests/MigrationTools.Clients.FileSystem.Tests.csproj +++ b/src/MigrationTools.Clients.FileSystem.Tests/MigrationTools.Clients.FileSystem.Tests.csproj @@ -22,6 +22,7 @@ + diff --git a/src/MigrationTools.Clients.FileSystem.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Clients.FileSystem.Tests/ServiceProviderHelper.cs index 58b89be60..c9a23d53f 100644 --- a/src/MigrationTools.Clients.FileSystem.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Clients.FileSystem.Tests/ServiceProviderHelper.cs @@ -1,4 +1,6 @@ using Microsoft.Extensions.DependencyInjection; +using MigrationTools.Fakes; +using MigrationTools.Services; using MigrationTools.TestExtensions; namespace MigrationTools.Tests @@ -13,6 +15,9 @@ internal static ServiceProvider GetServices() services.AddMigrationToolServices(); services.AddMigrationToolServicesForClientFileSystem(); + services.AddSingleton(); + services.AddSingleton(); + return services.BuildServiceProvider(); } } diff --git a/src/MigrationTools.Fakes/MigrationTools.Fakes.csproj b/src/MigrationTools.Fakes/MigrationTools.Helpers.Tests.csproj similarity index 100% rename from src/MigrationTools.Fakes/MigrationTools.Fakes.csproj rename to src/MigrationTools.Fakes/MigrationTools.Helpers.Tests.csproj diff --git a/src/MigrationTools.Integration.Tests/MigrationTools.Integration.Tests.csproj b/src/MigrationTools.Integration.Tests/MigrationTools.Integration.Tests.csproj index adc8f8cda..9d03ec9f4 100644 --- a/src/MigrationTools.Integration.Tests/MigrationTools.Integration.Tests.csproj +++ b/src/MigrationTools.Integration.Tests/MigrationTools.Integration.Tests.csproj @@ -29,6 +29,7 @@ + diff --git a/src/VstsSyncMigrator.Core.Tests/VstsSyncMigrator.Core.Tests.csproj b/src/VstsSyncMigrator.Core.Tests/VstsSyncMigrator.Core.Tests.csproj index 53f5696dd..a1ebe2cea 100644 --- a/src/VstsSyncMigrator.Core.Tests/VstsSyncMigrator.Core.Tests.csproj +++ b/src/VstsSyncMigrator.Core.Tests/VstsSyncMigrator.Core.Tests.csproj @@ -22,7 +22,7 @@ - + From c57577d52a8756714a79e8e5b54f3d0d388c4869 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Fri, 26 Jul 2024 14:26:16 +0100 Subject: [PATCH 13/14] =?UTF-8?q?=F0=9F=93=9D=20(docs):=20update=20Migrati?= =?UTF-8?q?onTools.xml=20with=20new=20commit=20details=20=E2=9C=85=20(test?= =?UTF-8?q?s):=20add=20project=20reference=20to=20MigrationTools.Helpers.T?= =?UTF-8?q?ests.csproj?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MigrationTools.xml file is updated to reflect the latest commit details, ensuring the documentation is accurate and up-to-date. The project reference to MigrationTools.Helpers.Tests.csproj is added to the test project file to include additional test helpers, improving the test coverage and maintainability. --- docs/Reference/Generated/MigrationTools.xml | 12 ++++++------ ...rationTools.Clients.AzureDevops.Rest.Tests.csproj | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/Reference/Generated/MigrationTools.xml b/docs/Reference/Generated/MigrationTools.xml index 7803ce90d..a0b92ea79 100644 --- a/docs/Reference/Generated/MigrationTools.xml +++ b/docs/Reference/Generated/MigrationTools.xml @@ -609,27 +609,27 @@ - => @"9b4dfe0" + => @"0e5f65f" - => @"9b4dfe0a5716b152c6c5382f37979ec30f2292d9" + => @"0e5f65ff4368b8da72e7e64991c4d0a095637a02" - => @"2024-07-26T13:58:26+01:00" + => @"2024-07-26T14:20:01+01:00" - => @"24" + => @"26" - => @"v15.1.5-Preview.2-24-g9b4dfe0" + => @"v15.1.5-Preview.2-26-g0e5f65f" @@ -664,7 +664,7 @@ - => @"29" + => @"31" diff --git a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj index 6f9d73233..d6e5a72e3 100644 --- a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj +++ b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj @@ -20,6 +20,7 @@ + From e050b124c75fed1d71bedc188a221876d3a1a516 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Fri, 26 Jul 2024 14:39:47 +0100 Subject: [PATCH 14/14] =?UTF-8?q?=E2=9C=85=20(csproj):=20add=20project=20r?= =?UTF-8?q?eference=20to=20MigrationTools.Helpers.Tests.csproj?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding the MigrationTools.Helpers.Tests.csproj reference ensures that the tests in MigrationTools.Clients.InMemory.Tests and MigrationTools.Tests projects can utilize the helper methods and utilities defined in MigrationTools.Helpers.Tests. This improves test coverage and code reuse. --- .../MigrationTools.Clients.InMemory.Tests.csproj | 1 + src/MigrationTools.Tests/MigrationTools.Tests.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj b/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj index 2f833e8b7..dd0a554e0 100644 --- a/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj +++ b/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj @@ -23,6 +23,7 @@ + diff --git a/src/MigrationTools.Tests/MigrationTools.Tests.csproj b/src/MigrationTools.Tests/MigrationTools.Tests.csproj index 1a5dfb9af..bc59cf9bf 100644 --- a/src/MigrationTools.Tests/MigrationTools.Tests.csproj +++ b/src/MigrationTools.Tests/MigrationTools.Tests.csproj @@ -22,6 +22,7 @@ +