Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centralise test logging setup into LoggerFixture #2023

Merged
merged 2 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2023-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Centralise test logging setup into LoggingFixture
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class ExtractImagesHostTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class HeaderPreservationTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class RabbitMQBrokerTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
_testOptions = new GlobalOptionsFactory().Load(nameof(RabbitMQBrokerTests));

_testProducerOptions = new ProducerOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class MongoQueryParserTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();

GlobalOptions globalOptions = new GlobalOptionsFactory().Load(nameof(MongoQueryParserTests));
_mongoOptions = globalOptions.MongoDatabases!.DicomStoreOptions!;
Expand Down
2 changes: 2 additions & 0 deletions tests/SmiServices.IntegrationTests/FixtureSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ internal class FixtureSetup
[OneTimeSetUp]
public void OneTimeSetUp()
{
UnitTests.LoggerFixture.Setup();

MessageHeader.CurrentProgramName = nameof(IntegrationTests);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ protected override void SetUp()
{
base.SetUp();

TestLogger.Setup();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class CohortPackagerHostTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ internal class ProgramTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class DicomAnonymiserHostTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public void Setup()
_helper = new DicomRelationalMapperTestHelper();
_helper.SetupSuite(db, RepositoryLocator, _globals, typeof(DicomDatasetCollectionSource));

TestLogger.Setup();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public class MicroservicesIntegrationTest : DatabaseTests

private void SetupSuite(DiscoveredDatabase server, bool persistentRaw = false, string? modalityPrefix = null)
{
TestLogger.Setup();

_globals = new GlobalOptionsFactory().Load(nameof(MicroservicesIntegrationTest));

_globals.UseTestValues(
Expand Down Expand Up @@ -422,7 +420,6 @@ public void IntegrationTest_BumpyRide(DatabaseType databaseType)
}
private void RunTest(DirectoryInfo dir, int numberOfExpectedRows, Action<FileSystemOptions>? adjustFileSystemOptions = null)
{
TestLogger.Setup();
var logger = LogManager.GetLogger("MicroservicesIntegrationTest");

_globals.FileSystemOptions!.FileSystemRoot = TestContext.CurrentContext.TestDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class FileCopierHostTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,6 @@ private static DicomFileMessage GetTestDicomFileMessage(Test testCase = Test.Nor
[Test]
public void TestIdentifierSwap_ControlQueueRefresh()
{
TestLogger.Setup();

var mockSwapper = new Mock<ISwapIdentifiers>();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class IsIdentifiableHostTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public class ImageMessageProcessorTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();

_helper = new MongoDbPopulatorTestHelper();
_helper.SetupSuite();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public class MessageProcessorTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();

_helper = new MongoDbPopulatorTestHelper();
_helper.SetupSuite();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public class SeriesMessageProcessorTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();

_helper = new MongoDbPopulatorTestHelper();
_helper.SetupSuite();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class AccessionDirectoryListerTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

private static string GetListContent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class DicomDirectoryFinderTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class PacsDirectoryFinderTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class ZipDicomDirectoryFinderTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class ProgramTests
public void OneTimeSetUp()
{
SmiCliInit.InitSmiLogging = false;
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class CohortCsvParserTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class ExtractImagesCliOptionsTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class ExtractionMessageSenderTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
1 change: 0 additions & 1 deletion tests/SmiServices.UnitTests/Common/EquTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class EquTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
1 change: 0 additions & 1 deletion tests/SmiServices.UnitTests/Common/LoggingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class LoggingTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class ExtractedFileStatusMessageTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class MessageHeaderTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ internal class ExponentialBackoffProviderTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ private class TestMessage : IMessage { }
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ internal class StaticBackoffProviderTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class SmiCliInitTests
public void OneTimeSetUp()
{
SmiCliInit.InitSmiLogging = false;
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
1 change: 0 additions & 1 deletion tests/SmiServices.UnitTests/Common/TestClassTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class TestClassTemplate
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
2 changes: 2 additions & 0 deletions tests/SmiServices.UnitTests/FixtureSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ internal class FixtureSetup
[OneTimeSetUp]
public void OneTimeSetUp()
{
LoggerFixture.Setup();

MessageHeader.CurrentProgramName = nameof(UnitTests);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using NLog.Config;
using NLog.Targets;

namespace SmiServices.UnitTests.Common
namespace SmiServices.UnitTests
{
public static class TestLogger
public static class LoggerFixture
{
private const string TestLoggerName = "TestLogger";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class DynamicRejectorTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class QueryToExecuteResultTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class ExtractionRequestQueueConsumerTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class NoSuffixProjectPathResolverTests
[SetUp]
public void SetUp()
{
TestLogger.Setup();
_fileSystem = new MockFileSystem();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class StudySeriesOriginalFilenameProjectPathResolverTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class StudySeriesSOPProjectPathResolverTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();

_requestMessage = new ExtractionRequestMessage
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class CompletedExtractJobInfoTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class ExtractJobInfoTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class ExtractJobStoreTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class ExtractionIdentifierRejectionInfoTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class FileAnonFailureInfoTest
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestLogger.Setup();
}

[OneTimeTearDown]
Expand Down
Loading