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

correction to cleanup in NonSessionLog tests #903

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 3 additions & 1 deletion UnitTests/Logger/FileLogTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public void TestGeneratedFileName()
Assert.That(File.Exists(Path.Combine(logDirectory, "FIX.4.2-SENDERCOMP-TARGETCOMP.event.current.log")));
Assert.That(File.Exists(Path.Combine(logDirectory, "FIX.4.2-SENDERCOMP-TARGETCOMP.messages.current.log")));

// cleanup
// cleanup (don't delete log unless success)
_log.Dispose();
_log = null;
Directory.Delete(logDirectory, true);
}

Expand Down
25 changes: 19 additions & 6 deletions UnitTests/Logger/NonSessionLogTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
public class NonSessionLogTests {
private readonly string _logDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "log");

private NonSessionLog? _nslog;

[TearDown]
public void Teardown()
{
_nslog?.Dispose();

Check failure on line 16 in UnitTests/Logger/NonSessionLogTests.cs

View workflow job for this annotation

GitHub Actions / build

'NonSessionLog' does not contain a definition for 'Dispose' and no accessible extension method 'Dispose' accepting a first argument of type 'NonSessionLog' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 16 in UnitTests/Logger/NonSessionLogTests.cs

View workflow job for this annotation

GitHub Actions / build

'NonSessionLog' does not contain a definition for 'Dispose' and no accessible extension method 'Dispose' accepting a first argument of type 'NonSessionLog' could be found (are you missing a using directive or an assembly reference?)
_nslog = null;
}

private FileLogFactory CreateFileLogFactory() {
if (Directory.Exists(_logDirectory))
Directory.Delete(_logDirectory, true);
Expand All @@ -32,34 +41,38 @@
[Test]
public void TestWithFileLogFactory() {
FileLogFactory flf = CreateFileLogFactory();
NonSessionLog nslog = new NonSessionLog(flf);
_nslog = new NonSessionLog(flf);

// Log artifact not created before first log-write
Assert.False(Directory.Exists(_logDirectory));

// Log artifact exists after first log-write
nslog.OnEvent("some text");
_nslog.OnEvent("some text");
Assert.True(Directory.Exists(_logDirectory));
Assert.True(File.Exists(Path.Combine(_logDirectory, "Non-Session-Log.event.current.log")));

// cleanup
// cleanup (don't delete log unless success)
_nslog.Dispose();

Check failure on line 55 in UnitTests/Logger/NonSessionLogTests.cs

View workflow job for this annotation

GitHub Actions / build

'NonSessionLog' does not contain a definition for 'Dispose' and no accessible extension method 'Dispose' accepting a first argument of type 'NonSessionLog' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in UnitTests/Logger/NonSessionLogTests.cs

View workflow job for this annotation

GitHub Actions / build

'NonSessionLog' does not contain a definition for 'Dispose' and no accessible extension method 'Dispose' accepting a first argument of type 'NonSessionLog' could be found (are you missing a using directive or an assembly reference?)
_nslog = null;
Directory.Delete(_logDirectory, true);
}

[Test]
public void TestWithCompositeLogFactory() {
CompositeLogFactory clf = new CompositeLogFactory([CreateFileLogFactory(), new NullLogFactory()]);
NonSessionLog nslog = new NonSessionLog(clf);
_nslog = new NonSessionLog(clf);

// Log artifact not created before first log-write
Assert.False(Directory.Exists(_logDirectory));

// Log artifact exists after first log-write
nslog.OnEvent("some text");
_nslog.OnEvent("some text");
Assert.True(Directory.Exists(_logDirectory));
Assert.True(File.Exists(Path.Combine(_logDirectory, "Non-Session-Log.event.current.log")));

// cleanup
// cleanup (don't delete log unless success)
_nslog.Dispose();

Check failure on line 74 in UnitTests/Logger/NonSessionLogTests.cs

View workflow job for this annotation

GitHub Actions / build

'NonSessionLog' does not contain a definition for 'Dispose' and no accessible extension method 'Dispose' accepting a first argument of type 'NonSessionLog' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 74 in UnitTests/Logger/NonSessionLogTests.cs

View workflow job for this annotation

GitHub Actions / build

'NonSessionLog' does not contain a definition for 'Dispose' and no accessible extension method 'Dispose' accepting a first argument of type 'NonSessionLog' could be found (are you missing a using directive or an assembly reference?)
_nslog = null;
Directory.Delete(_logDirectory, true);
}
}
Loading