Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
rkm committed Jan 6, 2025
1 parent 063a7d6 commit cb33bff
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using SmiServices.Microservices.DicomAnonymiser.Anonymisers;
using SmiServices.UnitTests.TestCommon;
using System.IO;
using System.IO.Abstractions;

namespace SmiServices.IntegrationTests.Microservices.DicomAnonymiser.Anonymisers;

Expand Down Expand Up @@ -33,9 +34,11 @@ public void Anonymise_HappyPath_IsOk()
var srcPath = Path.Combine(tempDir, "in.dcm");
srcDcm.Save(srcPath);
File.SetAttributes(srcPath, FileAttributes.ReadOnly);
var srcFile = new FileInfo(srcPath);

var fileSystem = new FileSystem();
var srcFile = fileSystem.FileInfo.New(srcPath);
var destPath = Path.Combine(tempDir, "out.dcm");
var destFile = new FileInfo(destPath);
var destFile = fileSystem.FileInfo.New(destPath);

using var anonymiser = new SmiCtpAnonymiser(globals);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Abstractions;
using System.Linq;
using System.Threading;

Expand Down Expand Up @@ -83,8 +84,8 @@ public void Integration_HappyPath_MockAnonymiser()
mockAnonymiser
.Setup(
x => x.Anonymise(
It.Is<FileInfo>(x => x.Name == _fakeDicom),
It.Is<FileInfo>(x => x.Name == Path.Combine(extractDirAbs.FullName, "foo-an.dcm")),
It.Is<IFileInfo>(x => x.Name == _fakeDicom),
It.Is<IFileInfo>(x => x.Name == Path.Combine(extractDirAbs.FullName, "foo-an.dcm")),
It.IsAny<string>(),
out It.Ref<string?>.IsAny
)
Expand All @@ -98,34 +99,34 @@ out It.Ref<string?>.IsAny

List<ExtractedFileStatusMessage> statusMessages = [];

using var tester = new MicroserviceTester(
globals.RabbitOptions!,
globals.DicomAnonymiserOptions.AnonFileConsumerOptions!
);
using var tester = new MicroserviceTester(
globals.RabbitOptions!,
globals.DicomAnonymiserOptions.AnonFileConsumerOptions!
);

tester.CreateExchange(statusExchange, successQueue, isSecondaryBinding: false, routingKey: "verify");
tester.CreateExchange(statusExchange, failureQueue, isSecondaryBinding: true, routingKey: "noverify");
tester.CreateExchange(statusExchange, successQueue, isSecondaryBinding: false, routingKey: "verify");
tester.CreateExchange(statusExchange, failureQueue, isSecondaryBinding: true, routingKey: "noverify");

tester.SendMessage(globals.DicomAnonymiserOptions.AnonFileConsumerOptions!, new MessageHeader(), testExtractFileMessage);
tester.SendMessage(globals.DicomAnonymiserOptions.AnonFileConsumerOptions!, new MessageHeader(), testExtractFileMessage);

var host = new DicomAnonymiserHost(globals, mockAnonymiser.Object);
var host = new DicomAnonymiserHost(globals, mockAnonymiser.Object);

host.Start();
host.Start();

var timeoutSecs = 10;
var timeoutSecs = 10;

while (statusMessages.Count == 0 && timeoutSecs > 0)
{
statusMessages.AddRange(tester.ConsumeMessages<ExtractedFileStatusMessage>(successQueue).Select(x => x.Item2));
statusMessages.AddRange(tester.ConsumeMessages<ExtractedFileStatusMessage>(failureQueue).Select(x => x.Item2));
while (statusMessages.Count == 0 && timeoutSecs > 0)
{
statusMessages.AddRange(tester.ConsumeMessages<ExtractedFileStatusMessage>(successQueue).Select(x => x.Item2));
statusMessages.AddRange(tester.ConsumeMessages<ExtractedFileStatusMessage>(failureQueue).Select(x => x.Item2));

--timeoutSecs;
if (statusMessages.Count == 0)
Thread.Sleep(TimeSpan.FromSeconds(1));
}
--timeoutSecs;
if (statusMessages.Count == 0)
Thread.Sleep(TimeSpan.FromSeconds(1));
}

host.Stop("Test end");
tester.Dispose();
host.Stop("Test end");
tester.Dispose();

var statusMessage = statusMessages.Single();
Assert.Multiple(() =>
Expand Down

0 comments on commit cb33bff

Please sign in to comment.