-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #900: NonSessionLog error with CompositeLog
#900 CompositeLog was using IFactory.Create instead of IFactory.CreateNonSessionLog
- Loading branch information
1 parent
c055302
commit 483a925
Showing
5 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System.IO; | ||
using NUnit.Framework; | ||
using QuickFix.Logger; | ||
|
||
namespace UnitTests.Logger; | ||
|
||
[TestFixture] | ||
public class NonSessionLogTests { | ||
private readonly string _logDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "log"); | ||
|
||
private FileLogFactory CreateFileLogFactory() { | ||
if (Directory.Exists(_logDirectory)) | ||
Directory.Delete(_logDirectory, true); | ||
|
||
string configString = $""" | ||
[DEFAULT] | ||
ConnectionType=initiator | ||
FileLogPath={_logDirectory} | ||
[SESSION] | ||
BeginString=FIX.4.2 | ||
SenderCompID=SENDERCOMP | ||
TargetCompID=TARGETCOMP | ||
"""; | ||
|
||
QuickFix.SessionSettings settings = new QuickFix.SessionSettings( | ||
new StringReader(configString)); | ||
|
||
return new FileLogFactory(settings); | ||
} | ||
|
||
[Test] | ||
public void TestWithFileLogFactory() { | ||
FileLogFactory flf = CreateFileLogFactory(); | ||
NonSessionLog 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"); | ||
Assert.True(Directory.Exists(_logDirectory)); | ||
Assert.True(File.Exists(Path.Combine(_logDirectory, "Non-Session-Log.event.current.log"))); | ||
|
||
// cleanup | ||
Directory.Delete(_logDirectory, true); | ||
} | ||
|
||
[Test] | ||
public void TestWithCompositeLogFactory() { | ||
CompositeLogFactory clf = new CompositeLogFactory([CreateFileLogFactory(), new NullLogFactory()]); | ||
NonSessionLog 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"); | ||
Assert.True(Directory.Exists(_logDirectory)); | ||
Assert.True(File.Exists(Path.Combine(_logDirectory, "Non-Session-Log.event.current.log"))); | ||
|
||
// cleanup | ||
Directory.Delete(_logDirectory, true); | ||
} | ||
} |