Skip to content

Commit 22c23d2

Browse files
committed
Fix unit test
Signed-off-by: Neil South <[email protected]>
1 parent fa9dbeb commit 22c23d2

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

src/InformaticsGateway/ExecutionPlugins/ExternalAppIncoming.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
using System;
18+
using System.Reflection;
1819
using System.Threading.Tasks;
1920
using FellowOakDicom;
2021
using Microsoft.Extensions.DependencyInjection;
@@ -36,7 +37,7 @@ public class ExternalAppIncoming : IInputDataPlugin
3637
private readonly IServiceScopeFactory _serviceScopeFactory;
3738
private readonly PluginConfiguration _options;
3839

39-
public string Name => "Remote App Execution Incoming";
40+
public string Name => GetType().GetCustomAttribute<PluginNameAttribute>()?.Name ?? GetType().Name;
4041
public ExternalAppIncoming(
4142
ILogger<ExternalAppIncoming> logger,
4243
IServiceScopeFactory serviceScopeFactory,

src/InformaticsGateway/ExecutionPlugins/ExternalAppOutgoing.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
using System;
18+
using System.Reflection;
1819
using System.Threading;
1920
using System.Threading.Tasks;
2021
using FellowOakDicom;
@@ -36,7 +37,7 @@ public class ExternalAppOutgoing : IOutputDataPlugin
3637
private readonly IServiceScopeFactory _serviceScopeFactory;
3738
private readonly PluginConfiguration _options;
3839

39-
public string Name => "Remote App Execution Outgoing";
40+
public string Name => GetType().GetCustomAttribute<PluginNameAttribute>()?.Name ?? GetType().Name;
4041

4142
public ExternalAppOutgoing(
4243
ILogger<ExternalAppOutgoing> logger,

src/InformaticsGateway/Test/Services/Common/InputDataPluginEngineFactoryTest.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
using System;
1818
using System.Collections.Generic;
1919
using System.IO.Abstractions;
20+
using System.Reflection;
2021
using Microsoft.Extensions.Logging;
2122
using Monai.Deploy.InformaticsGateway.Api;
2223
using Monai.Deploy.InformaticsGateway.Common;
24+
using Monai.Deploy.InformaticsGateway.ExecutionPlugins;
2325
using Monai.Deploy.InformaticsGateway.Services.Common;
2426
using Monai.Deploy.InformaticsGateway.SharedTest;
2527
using Monai.Deploy.InformaticsGateway.Test.Plugins;
@@ -52,17 +54,19 @@ public void RegisteredPlugins_WhenCalled_ReturnsListOfPlugins()
5254
p => VerifyPlugin(p, typeof(TestInputDataPluginAddWorkflow)),
5355
p => VerifyPlugin(p, typeof(TestInputDataPluginResumeWorkflow)),
5456
p => VerifyPlugin(p, typeof(TestInputDataPluginModifyDicomFile)),
55-
p => VerifyPlugin(p, typeof(TestInputDataPluginVirtualAE)));
57+
p => VerifyPlugin(p, typeof(TestInputDataPluginVirtualAE)),
58+
p => VerifyPlugin(p, typeof(ExternalAppIncoming)));
5659

57-
_logger.VerifyLogging($"{typeof(IInputDataPlugin).Name} data plug-in found {typeof(TestInputDataPluginAddWorkflow).Name}: {typeof(TestInputDataPluginAddWorkflow).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
58-
_logger.VerifyLogging($"{typeof(IInputDataPlugin).Name} data plug-in found {typeof(TestInputDataPluginResumeWorkflow).Name}: {typeof(TestInputDataPluginResumeWorkflow).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
59-
_logger.VerifyLogging($"{typeof(IInputDataPlugin).Name} data plug-in found {typeof(TestInputDataPluginModifyDicomFile).Name}: {typeof(TestInputDataPluginModifyDicomFile).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
60-
_logger.VerifyLogging($"{typeof(IInputDataPlugin).Name} data plug-in found {typeof(TestInputDataPluginVirtualAE).Name}: {typeof(TestInputDataPluginVirtualAE).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
60+
_logger.VerifyLogging($"{typeof(IInputDataPlugin).Name} data plug-in found {typeof(TestInputDataPluginAddWorkflow).GetCustomAttribute<PluginNameAttribute>()?.Name}: {typeof(TestInputDataPluginAddWorkflow).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
61+
_logger.VerifyLogging($"{typeof(IInputDataPlugin).Name} data plug-in found {typeof(TestInputDataPluginResumeWorkflow).GetCustomAttribute<PluginNameAttribute>()?.Name}: {typeof(TestInputDataPluginResumeWorkflow).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
62+
_logger.VerifyLogging($"{typeof(IInputDataPlugin).Name} data plug-in found {typeof(TestInputDataPluginModifyDicomFile).GetCustomAttribute<PluginNameAttribute>()?.Name}: {typeof(TestInputDataPluginModifyDicomFile).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
63+
_logger.VerifyLogging($"{typeof(IInputDataPlugin).Name} data plug-in found {typeof(TestInputDataPluginVirtualAE).GetCustomAttribute<PluginNameAttribute>()?.Name}: {typeof(TestInputDataPluginVirtualAE).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
64+
_logger.VerifyLogging($"{typeof(IInputDataPlugin).Name} data plug-in found {typeof(ExternalAppIncoming).GetCustomAttribute<PluginNameAttribute>()?.Name}: {typeof(ExternalAppIncoming).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
6165
}
6266

6367
private void VerifyPlugin(KeyValuePair<string, string> values, Type type)
6468
{
65-
Assert.Equal(values.Key, type.Name);
69+
Assert.Equal(values.Key, type.GetCustomAttribute<PluginNameAttribute>()?.Name);
6670
Assert.Equal(values.Value, type.GetShortTypeAssemblyName());
6771
}
6872
}

src/InformaticsGateway/Test/Services/Common/OutputDataPluginEngineFactoryTest.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
using System;
1818
using System.Collections.Generic;
1919
using System.IO.Abstractions;
20+
using System.Reflection;
2021
using Microsoft.Extensions.Logging;
2122
using Monai.Deploy.InformaticsGateway.Api;
2223
using Monai.Deploy.InformaticsGateway.Common;
24+
using Monai.Deploy.InformaticsGateway.ExecutionPlugins;
2325
using Monai.Deploy.InformaticsGateway.Services.Common;
2426
using Monai.Deploy.InformaticsGateway.SharedTest;
2527
using Monai.Deploy.InformaticsGateway.Test.Plugins;
@@ -50,15 +52,18 @@ public void RegisteredPlugins_WhenCalled_ReturnsListOfPlugins()
5052

5153
Assert.Collection(result,
5254
p => VerifyPlugin(p, typeof(TestOutputDataPluginAddMessage)),
53-
p => VerifyPlugin(p, typeof(TestOutputDataPluginModifyDicomFile)));
55+
p => VerifyPlugin(p, typeof(TestOutputDataPluginModifyDicomFile)),
56+
p => VerifyPlugin(p, typeof(ExternalAppOutgoing))
57+
);
5458

55-
_logger.VerifyLogging($"{typeof(IOutputDataPlugin).Name} data plug-in found {typeof(TestOutputDataPluginAddMessage).Name}: {typeof(TestOutputDataPluginAddMessage).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
56-
_logger.VerifyLogging($"{typeof(IOutputDataPlugin).Name} data plug-in found {typeof(TestOutputDataPluginModifyDicomFile).Name}: {typeof(TestOutputDataPluginModifyDicomFile).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
59+
_logger.VerifyLogging($"{typeof(IOutputDataPlugin).Name} data plug-in found {typeof(TestOutputDataPluginAddMessage).GetCustomAttribute<PluginNameAttribute>()?.Name}: {typeof(TestOutputDataPluginAddMessage).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
60+
_logger.VerifyLogging($"{typeof(IOutputDataPlugin).Name} data plug-in found {typeof(TestOutputDataPluginModifyDicomFile).GetCustomAttribute<PluginNameAttribute>()?.Name}: {typeof(TestOutputDataPluginModifyDicomFile).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
61+
_logger.VerifyLogging($"{typeof(IOutputDataPlugin).Name} data plug-in found {typeof(ExternalAppOutgoing).GetCustomAttribute<PluginNameAttribute>()?.Name}: {typeof(ExternalAppOutgoing).GetShortTypeAssemblyName()}.", LogLevel.Information, Times.Once());
5762
}
5863

5964
private void VerifyPlugin(KeyValuePair<string, string> values, Type type)
6065
{
61-
Assert.Equal(values.Key, type.Name);
66+
Assert.Equal(values.Key, type.GetCustomAttribute<PluginNameAttribute>()?.Name);
6267
Assert.Equal(values.Value, type.GetShortTypeAssemblyName());
6368
}
6469
}

0 commit comments

Comments
 (0)