Skip to content

Commit

Permalink
Update all
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHinsh committed Aug 27, 2024
1 parent 2f46086 commit 825070d
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 239 deletions.
10 changes: 5 additions & 5 deletions configuration-classic.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@
}
},
{
"$type": "FieldtoFieldMapOptions",
"$type": "FieldToFieldMapOptions",
"WorkItemTypeName": "*",
"sourceField": "Microsoft.VSTS.Common.BacklogPriority",
"targetField": "Microsoft.VSTS.Common.StackRank",
"defaultValue": null
},
{
"$type": "FieldtoFieldMultiMapOptions",
"$type": "FieldToFieldMultiMapOptions",
"WorkItemTypeName": "*",
"SourceToTargetMappings": {
"SourceField1": "TargetField1",
"SourceField2": "TargetField2"
}
},
{
"$type": "FieldtoTagMapOptions",
"$type": "FieldToTagFieldMapOptions",
"WorkItemTypeName": "*",
"sourceField": "System.State",
"formatExpression": "ScrumState:{0}"
Expand All @@ -104,14 +104,14 @@
"replacement": "$1"
},
{
"$type": "FieldValuetoTagMapOptions",
"$type": "FieldValueToTagMapOptions",
"WorkItemTypeName": "*",
"sourceField": "Microsoft.VSTS.CMMI.Blocked",
"pattern": "Yes",
"formatExpression": "{0}"
},
{
"$type": "TreeToTagMapOptions",
"$type": "TreeToTagFieldMapOptions",
"WorkItemTypeName": "*",
"toSkip": 3,
"timeTravel": 1
Expand Down
14 changes: 7 additions & 7 deletions docs/Reference/Generated/MigrationTools.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public FieldValuetoTagMap(ILogger<FieldValuetoTagMap> logger, ITelemetryLogger t
}

public override string MappingDisplayName => $"{Config.sourceField}";
private FieldValuetoTagMapOptions Config { get { return (FieldValuetoTagMapOptions)_Config; } }
private FieldValueToTagMapOptions Config { get { return (FieldValueToTagMapOptions)_Config; } }

public override void Configure(IFieldMapOptions config)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,53 @@
using Microsoft.Extensions.DependencyInjection;
using System.Xml.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MigrationTools.DataContracts;
using MigrationTools.EndpointEnrichers;
using MigrationTools.Enrichers;
using MigrationTools.Tests;
using MigrationTools.Tools;
using MigrationTools.Tools.Interfaces;
using MigrationTools.Tools.Shadows;
using MigrationTools.Shadows;
using System;

namespace MigrationTools.Endpoints.Tests
{
[TestClass()]
public class FileSystemWorkItemEndpointTests
{
public ServiceProvider Services { get; private set; }

public IServiceProvider Services { get; private set; }

[TestInitialize]
public void Setup()
{
Services = ServiceProviderHelper.GetServices();
Services = GetServices();
}

[TestMethod, TestCategory("L3")]
public void ConfiguredTest()
{
FileSystemWorkItemEndpoint e = CreateEndpoint("Source");
FileSystemWorkItemEndpoint e = (FileSystemWorkItemEndpoint)Services.GetKeyedService<IEndpoint>("Source");
CleanAndAdd(e, 10);
Assert.AreEqual(10, e.Count);
}

[TestMethod, TestCategory("L3")]
public void EmptyTest()
{
FileSystemWorkItemEndpoint e = CreateEndpoint("Source");
FileSystemWorkItemEndpoint e = (FileSystemWorkItemEndpoint)Services.GetKeyedService<IEndpoint>("Source");
CleanAndAdd(e, 0);
Assert.AreEqual(0, e.Count);
}

[TestMethod, TestCategory("L3")]
public void FilterAllTest()
{
FileSystemWorkItemEndpoint e1 = CreateEndpoint("Source");
FileSystemWorkItemEndpoint e1 = (FileSystemWorkItemEndpoint)Services.GetKeyedService<IEndpoint>("Source");
CleanAndAdd(e1, 10);
FileSystemWorkItemEndpoint e2 = CreateEndpoint("Target");
FileSystemWorkItemEndpoint e2 = (FileSystemWorkItemEndpoint)Services.GetKeyedService<IEndpoint>("Target");
CleanAndAdd(e2, 10);

e1.Filter(e2.GetWorkItems());
Expand All @@ -48,9 +57,9 @@ public void FilterAllTest()
[TestMethod, TestCategory("L3")]
public void FilterHalfTest()
{
FileSystemWorkItemEndpoint e1 = CreateEndpoint("Source");
FileSystemWorkItemEndpoint e1 = (FileSystemWorkItemEndpoint)Services.GetKeyedService<IEndpoint>("Source");
CleanAndAdd(e1, 20);
FileSystemWorkItemEndpoint e2 = CreateEndpoint("Target");
FileSystemWorkItemEndpoint e2 = (FileSystemWorkItemEndpoint)Services.GetKeyedService<IEndpoint>("Target");
CleanAndAdd(e2, 10);
e1.Filter(e2.GetWorkItems());
Assert.AreEqual(10, e1.Count);
Expand All @@ -59,9 +68,9 @@ public void FilterHalfTest()
[TestMethod, TestCategory("L3")]
public void PersistWorkItemExistsTest()
{
FileSystemWorkItemEndpoint e1 = CreateEndpoint("Source");
FileSystemWorkItemEndpoint e1 = (FileSystemWorkItemEndpoint)Services.GetKeyedService<IEndpoint>("Source");
CleanAndAdd(e1, 20);
FileSystemWorkItemEndpoint e2 = CreateEndpoint("Target");
FileSystemWorkItemEndpoint e2 = (FileSystemWorkItemEndpoint)Services.GetKeyedService<IEndpoint>("Target");
CleanAndAdd(e2, 10);

foreach (WorkItemData item in e1.GetWorkItems())
Expand All @@ -74,9 +83,9 @@ public void PersistWorkItemExistsTest()
[TestMethod, TestCategory("L3")]
public void PersistWorkItemWithFilterTest()
{
FileSystemWorkItemEndpoint e1 = CreateEndpoint("Source");
FileSystemWorkItemEndpoint e1 = (FileSystemWorkItemEndpoint)Services.GetKeyedService<IEndpoint>("Source");
CleanAndAdd(e1, 20);
FileSystemWorkItemEndpoint e2 = CreateEndpoint("Target");
FileSystemWorkItemEndpoint e2 = (FileSystemWorkItemEndpoint)Services.GetKeyedService<IEndpoint>("Target");
CleanAndAdd(e2, 10);
e1.Filter(e2.GetWorkItems());
Assert.AreEqual(10, e1.Count);
Expand All @@ -99,12 +108,41 @@ public void CleanAndAdd(FileSystemWorkItemEndpoint endpoint, int count)
}
}

private FileSystemWorkItemEndpoint CreateEndpoint(string direction)
protected IServiceProvider GetServices()
{
var options = new FileSystemWorkItemEndpointOptions() { FileStore = string.Format(@".\Store\{0}\", direction) };
IOptions<FileSystemWorkItemEndpointOptions> wrappedOptions = Microsoft.Extensions.Options.Options.Create(options);
FileSystemWorkItemEndpoint e = ActivatorUtilities.CreateInstance<FileSystemWorkItemEndpoint>(Services, wrappedOptions);
return e;
var services = new ServiceCollection();
services.AddMigrationToolServicesForUnitTests();

services.AddSingleton<ProcessorEnricherContainer>();
services.AddSingleton<EndpointEnricherContainer>();
services.AddSingleton<CommonTools>();
services.AddSingleton<IFieldMappingTool, MockFieldMappingTool>();
services.AddSingleton<IWorkItemTypeMappingTool, MockWorkItemTypeMappingTool>();
services.AddSingleton<IStringManipulatorTool, StringManipulatorTool>();

services.AddKeyedSingleton(typeof(IEndpoint), "Source", (sp, key) =>
{
IOptions<FileSystemWorkItemEndpointOptions> options = Microsoft.Extensions.Options.Options.Create(new FileSystemWorkItemEndpointOptions()
{
FileStore = @".\Store\Source\"
});
var endpoint = ActivatorUtilities.CreateInstance(sp, typeof(FileSystemWorkItemEndpoint), options);
return endpoint;
});

services.AddKeyedSingleton(typeof(IEndpoint), "Target", (sp, key) =>
{
IOptions<FileSystemWorkItemEndpointOptions> options = Microsoft.Extensions.Options.Options.Create(new FileSystemWorkItemEndpointOptions()
{
FileStore = @".\Store\Target\"
});
var endpoint = ActivatorUtilities.CreateInstance(sp, typeof(FileSystemWorkItemEndpoint), options);
return endpoint;
});


return services.BuildServiceProvider();
}

}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
using Microsoft.Extensions.DependencyInjection;
using MigrationTools.Services;
using Microsoft.Extensions.Configuration;
using MigrationTools.Services.Shadows;
using MigrationTools.Shadows;
//using Microsoft.Extensions.DependencyInjection;
//using MigrationTools.Services;
//using Microsoft.Extensions.Configuration;
//using MigrationTools.Services.Shadows;
//using MigrationTools.Shadows;

namespace MigrationTools.Tests
{
internal static class ServiceProviderHelper
{
internal static ServiceProvider GetServices()
{
var configuration = new ConfigurationBuilder().Build();
var services = new ServiceCollection();
services.AddMigrationToolServicesForUnitTests();
//namespace MigrationTools.Tests
//{
// internal static class ServiceProviderHelper
// {
// internal static ServiceProvider GetServices()
// {
// var configuration = new ConfigurationBuilder().Build();
// var services = new ServiceCollection();
// services.AddMigrationToolServicesForUnitTests();

services.AddMigrationToolServices(configuration);
services.AddMigrationToolServicesForClientFileSystem(configuration);
// services.AddMigrationToolServices(configuration);
// services.AddMigrationToolServicesForClientFileSystem(configuration);

services.AddSingleton<IMigrationToolVersionInfo, FakeMigrationToolVersionInfo>();
services.AddSingleton<IMigrationToolVersion, FakeMigrationToolVersion>();
// services.AddSingleton<IMigrationToolVersionInfo, FakeMigrationToolVersionInfo>();
// services.AddSingleton<IMigrationToolVersion, FakeMigrationToolVersion>();

return services.BuildServiceProvider();
}
}
}
// return services.BuildServiceProvider();
// }
// }
//}
Loading

0 comments on commit 825070d

Please sign in to comment.