Merge branch 'review/wp6' into review/integration
# Conflicts: # docs/requirements/Component-StoreAndForward.md # src/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase/Repositories/DeploymentManagerRepository.cs # src/ZB.MOM.WW.ScadaBridge.StoreAndForward/StoreAndForwardStorage.cs # src/ZB.MOM.WW.ScadaBridge.Transport/Import/BundleImporter.cs # tests/ZB.MOM.WW.ScadaBridge.StoreAndForward.Tests/StoreAndForwardStorageTests.cs
This commit is contained in:
@@ -1192,6 +1192,9 @@ public class ManagementActorTests : TestKit, IDisposable
|
||||
// (review 2026-10-21 04/P6, 08/P1).
|
||||
_templateRepo.GetAllTemplatesForAnalysisAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Template> { template });
|
||||
// TPL-4: SetAlarmOverride reads the template's analysis closure, not the whole table.
|
||||
_templateRepo.GetTemplateAnalysisClosureAsync(template.Id, Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Template> { template });
|
||||
_templateRepo.GetAlarmOverrideAsync(10, "HighTemp", Arg.Any<CancellationToken>())
|
||||
.Returns((InstanceAlarmOverride?)null);
|
||||
|
||||
@@ -4071,14 +4074,15 @@ public class ManagementActorTests : TestKit, IDisposable
|
||||
|
||||
// The repository fan-out HandleExportBundle does at the top of its body.
|
||||
// Tests that only exercise role gating still need these resolved.
|
||||
_templateRepo.GetAllTemplatesAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Template>());
|
||||
// MGT-5: template and instance names resolve against narrow projections.
|
||||
_templateRepo.GetTemplateStubsAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Commons.Types.Templates.TemplateStub>());
|
||||
_templateRepo.GetAllSharedScriptsAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Commons.Entities.Scripts.SharedScript>());
|
||||
// Export now also fans out to instances (template repo) and sites
|
||||
// (site repo) for the site/instance-scoped selection.
|
||||
_templateRepo.GetAllInstancesAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Instance>());
|
||||
_templateRepo.GetInstanceNamesAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<(int, string)>());
|
||||
|
||||
var siteRepo = Substitute.For<ISiteRepository>();
|
||||
siteRepo.GetAllSitesAsync(Arg.Any<CancellationToken>())
|
||||
@@ -4234,8 +4238,8 @@ public class ManagementActorTests : TestKit, IDisposable
|
||||
// curated message must surface verbatim to the caller.
|
||||
AddBundleSubstitutes();
|
||||
// No templates in the repo; the export selection names one anyway.
|
||||
_templateRepo.GetAllTemplatesAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Template>());
|
||||
_templateRepo.GetTemplateStubsAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Commons.Types.Templates.TemplateStub>());
|
||||
|
||||
var cmd = new ExportBundleCommand(
|
||||
All: false,
|
||||
@@ -4260,6 +4264,36 @@ public class ManagementActorTests : TestKit, IDisposable
|
||||
Assert.Contains("DoesNotExist", response.Error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MGT-5 (WP6 6.7): export resolves names against the (Id, Name) projections and never
|
||||
/// materialises the full template graph or every instance with its child collections.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ExportBundleCommand_ResolvesNamesFromProjections_NotFullGraphs()
|
||||
{
|
||||
var (exporter, _) = AddBundleSubstitutes();
|
||||
_templateRepo.GetTemplateStubsAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Commons.Types.Templates.TemplateStub> { new(7, "PumpBase", null, null, false, null) });
|
||||
Commons.Types.Transport.ExportSelection? captured = null;
|
||||
exporter.ExportAsync(
|
||||
Arg.Do<Commons.Types.Transport.ExportSelection>(s => captured = s),
|
||||
Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string?>(),
|
||||
Arg.Any<CancellationToken>())
|
||||
.Returns(_ => Task.FromResult<Stream>(new MemoryStream(new byte[] { 1 })));
|
||||
|
||||
var cmd = new ExportBundleCommand(
|
||||
All: false, TemplateNames: new[] { "PumpBase" }, SharedScriptNames: null,
|
||||
ExternalSystemNames: null, DatabaseConnectionNames: null,
|
||||
NotificationListNames: null, SmtpConfigurationNames: null, ApiMethodNames: null,
|
||||
IncludeDependencies: false, Passphrase: null, SourceEnvironment: "test-env");
|
||||
CreateActor().Tell(Envelope(cmd, "Designer"));
|
||||
|
||||
ExpectMsg<ManagementSuccess>(TimeSpan.FromSeconds(5));
|
||||
Assert.Equal(new[] { 7 }, captured!.TemplateIds);
|
||||
_templateRepo.DidNotReceive().GetAllTemplatesAsync(Arg.Any<CancellationToken>());
|
||||
_templateRepo.DidNotReceive().GetAllInstancesAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
/// <summary>Verifies that export bundle command, when with site and instance names, resolves to ids.</summary>
|
||||
[Fact]
|
||||
public void ExportBundleCommand_WithSiteAndInstanceNames_ResolvesToIds()
|
||||
@@ -4277,12 +4311,8 @@ public class ManagementActorTests : TestKit, IDisposable
|
||||
new("North Plant", "NORTH-01") { Id = 11 },
|
||||
new("East Plant", "EAST-02") { Id = 22 },
|
||||
});
|
||||
_templateRepo.GetAllInstancesAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Instance>
|
||||
{
|
||||
new("NORTH-01.Pump1") { Id = 101, SiteId = 11, TemplateId = 1 },
|
||||
new("NORTH-01.Pump2") { Id = 102, SiteId = 11, TemplateId = 1 },
|
||||
});
|
||||
_templateRepo.GetInstanceNamesAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<(int, string)> { (101, "NORTH-01.Pump1"), (102, "NORTH-01.Pump2") });
|
||||
|
||||
Commons.Types.Transport.ExportSelection? captured = null;
|
||||
exporter.ExportAsync(
|
||||
@@ -4328,12 +4358,8 @@ public class ManagementActorTests : TestKit, IDisposable
|
||||
new("North Plant", "NORTH-01") { Id = 11 },
|
||||
new("East Plant", "EAST-02") { Id = 22 },
|
||||
});
|
||||
_templateRepo.GetAllInstancesAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Instance>
|
||||
{
|
||||
new("NORTH-01.Pump1") { Id = 101, SiteId = 11, TemplateId = 1 },
|
||||
new("EAST-02.Pump9") { Id = 909, SiteId = 22, TemplateId = 1 },
|
||||
});
|
||||
_templateRepo.GetInstanceNamesAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<(int, string)> { (101, "NORTH-01.Pump1"), (909, "EAST-02.Pump9") });
|
||||
|
||||
Commons.Types.Transport.ExportSelection? captured = null;
|
||||
exporter.ExportAsync(
|
||||
|
||||
Reference in New Issue
Block a user