Skip to content

Commit 5b3d33a

Browse files
authored
Fix for #136 (#137)
The type data passed to retrieve the background-operation-manager-registered command was incorrect, so commands were not returned correctly. As the commands were not returned correctly, clicking the button on the dashboard didn't wire up the click event for the command. Resolved issue and added unit test to ensure that these sorts of commands are returned.
1 parent c5c2244 commit 5b3d33a

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

MFiles.VAF.Extensions.Tests/ConfigurableVaultApplicationBaseTests/ConfigurableVaultApplicationBaseTests.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using MFiles.VAF.Configuration;
88
using System.Collections.Generic;
99
using MFiles.VAF.Extensions.Dashboards.Commands.CustomDomainCommandResolution;
10+
using System.Linq;
1011

1112
namespace MFiles.VAF.Extensions.Tests
1213
{
@@ -24,6 +25,45 @@ public void GetCustomDomainCommandResolver_Default()
2425
Assert.IsNotNull(resolver);
2526
Assert.IsInstanceOfType(resolver, typeof(DefaultCustomDomainCommandResolver<object>));
2627
}
28+
29+
[TestMethod]
30+
public void TaskQueueBackgroundOperationsManager_ReturnsCommands()
31+
{
32+
var proxy = new ConfigurableVaultApplicationBaseProxy<object>();
33+
34+
var vaultMock = new Mock<Vault>();
35+
vaultMock
36+
.Setup(m => m.GetVaultServerAttachments())
37+
.Returns(() =>
38+
{
39+
var attachments = new VaultServerAttachments();
40+
attachments.Add(0, new VaultServerAttachment());
41+
return attachments;
42+
});
43+
vaultMock.SetupGet(m => m.ApplicationTaskOperations).Returns(Mock.Of<VaultApplicationTaskOperations>());
44+
45+
// Create a background operation and set it up so the command should be returned.
46+
proxy.TaskManager = new TaskManagerEx<object>
47+
(
48+
proxy,
49+
"taskManager",
50+
vaultMock.Object,
51+
Mock.Of<IVaultTransactionRunner>()
52+
);
53+
var operation = proxy.TaskQueueBackgroundOperationManager.CreateBackgroundOperation("test", () => { });
54+
55+
// Ensure that the domain resolver returns the command.
56+
var returnedCommands = proxy
57+
.GetCustomDomainCommandResolver()?
58+
.GetCustomDomainCommands()?
59+
.ToList() ?? new List<VAF.Configuration.AdminConfigurations.CustomDomainCommand>();
60+
Assert.IsTrue
61+
(
62+
returnedCommands?
63+
.Contains(operation.DashboardRunCommand) ?? false
64+
);
65+
66+
}
2767
}
2868

2969
public class ConfigurableVaultApplicationBaseProxy<TSecureConfigurationType>
@@ -40,6 +80,15 @@ public class ConfigurableVaultApplicationBaseProxy<TSecureConfigurationType>
4080
get => base.ConfigurationStorage;
4181
set => base.ConfigurationStorage = value;
4282
}
83+
protected internal new TaskQueueBackgroundOperationManager<TSecureConfigurationType> TaskQueueBackgroundOperationManager
84+
{
85+
get { return base.TaskQueueBackgroundOperationManager; }
86+
}
87+
protected internal new TaskManagerEx<TSecureConfigurationType> TaskManager
88+
{
89+
get { return base.TaskManager; }
90+
set { base.TaskManager = value; }
91+
}
4392
}
4493
public class ConfigurableVaultApplicationBaseProxy
4594
: ConfigurableVaultApplicationBaseProxy<object>

MFiles.VAF.Extensions/Dashboards/Commands/CustomDomainCommandResolution/AsynchronousOperationCustomDomainCommandResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected virtual IEnumerable<CustomDomainCommand> GetTaskQueueBackgroundOperati
5353
// Get the background operations that have a run command.
5454
// Note: this should be all of them.
5555
foreach (var c in
56-
GetType()
56+
VaultApplication.GetType()
5757
.GetPropertiesAndFieldsOfType<TaskQueueBackgroundOperationManager<TSecureConfiguration>>(VaultApplication)
5858
.SelectMany(tqbom => tqbom.BackgroundOperations)
5959
.AsEnumerable()

0 commit comments

Comments
 (0)