diff --git a/news/1799-bugfix.md b/news/1799-bugfix.md new file mode 100644 index 000000000..c773b31a9 --- /dev/null +++ b/news/1799-bugfix.md @@ -0,0 +1 @@ +Re-add a parameterless constructor to DynamicRejector so it can be loaded via reflection in CohortExtractorHost. diff --git a/src/microservices/Microservices.CohortExtractor/Execution/RequestFulfillers/Dynamic/DynamicRejector.cs b/src/microservices/Microservices.CohortExtractor/Execution/RequestFulfillers/Dynamic/DynamicRejector.cs index faa7e2f10..0cde6d169 100644 --- a/src/microservices/Microservices.CohortExtractor/Execution/RequestFulfillers/Dynamic/DynamicRejector.cs +++ b/src/microservices/Microservices.CohortExtractor/Execution/RequestFulfillers/Dynamic/DynamicRejector.cs @@ -12,11 +12,12 @@ public class DynamicRejector : IRejector private readonly Script _script; private const string DefaultDynamicRulesPath = "./DynamicRules.txt"; + public DynamicRejector() + : this(null) {} + public DynamicRejector(string? dynamicRulesPath, IFileSystem? fileSystem = null) { - if (dynamicRulesPath == null) - dynamicRulesPath = DefaultDynamicRulesPath; - + dynamicRulesPath ??= DefaultDynamicRulesPath; fileSystem ??= new FileSystem(); if (!fileSystem.File.Exists(dynamicRulesPath)) diff --git a/tests/microservices/Microservices.CohortExtractor.Tests/Execution/RequestFulfillers/Dynamic/DynamicRejectorTests.cs b/tests/microservices/Microservices.CohortExtractor.Tests/Execution/RequestFulfillers/Dynamic/DynamicRejectorTests.cs index 4e5491887..26a2c1bd5 100644 --- a/tests/microservices/Microservices.CohortExtractor.Tests/Execution/RequestFulfillers/Dynamic/DynamicRejectorTests.cs +++ b/tests/microservices/Microservices.CohortExtractor.Tests/Execution/RequestFulfillers/Dynamic/DynamicRejectorTests.cs @@ -40,5 +40,11 @@ public void Constructor_MissingRulesFile_Throws() Assert.Throws(() => new DynamicRejector("foo.txt", new MockFileSystem())); } + [Test] + public void Constructor_ExistsWithNoArgs() + { + _ = new DynamicRejector(); + } + #endregion }