55namespace UnitTests . Logger ;
66
77[ TestFixture ]
8- public class NonSessionLogTests {
8+ public class NonSessionLogTests
9+ {
910 private readonly string _logDirectory = Path . Combine ( TestContext . CurrentContext . TestDirectory , "log" ) ;
1011
11- private NonSessionLog ? _nslog ;
12-
1312 [ TearDown ]
1413 public void Teardown ( )
1514 {
16- _nslog ? . Dispose ( ) ;
17- _nslog = null ;
1815 }
19-
20- private FileLogFactory CreateFileLogFactory ( ) {
16+
17+ private FileLogFactory CreateFileLogFactory ( )
18+ {
2119 if ( Directory . Exists ( _logDirectory ) )
2220 Directory . Delete ( _logDirectory , true ) ;
2321
@@ -32,47 +30,59 @@ private FileLogFactory CreateFileLogFactory() {
3230 TargetCompID=TARGETCOMP
3331 """ ;
3432
35- QuickFix . SessionSettings settings = new QuickFix . SessionSettings (
33+ QuickFix . SessionSettings settings = new (
3634 new StringReader ( configString ) ) ;
3735
3836 return new FileLogFactory ( settings ) ;
3937 }
4038
4139 [ Test ]
42- public void TestWithFileLogFactory ( ) {
40+ public void TestWithFileLogFactory ( )
41+ {
4342 FileLogFactory flf = CreateFileLogFactory ( ) ;
44- _nslog = new NonSessionLog ( flf ) ;
43+ NonSessionLog nslog = new ( flf ) ;
4544
4645 // Log artifact not created before first log-write
4746 Assert . That ( Directory . Exists ( _logDirectory ) , Is . False ) ;
4847
4948 // Log artifact exists after first log-write
50- _nslog . OnEvent ( "some text" ) ;
49+ nslog . OnEvent ( "some text" ) ;
5150 Assert . That ( Directory . Exists ( _logDirectory ) ) ;
5251 Assert . That ( File . Exists ( Path . Combine ( _logDirectory , "Non-Session-Log.event.current.log" ) ) ) ;
5352
5453 // cleanup (don't delete log unless success)
55- _nslog . Dispose ( ) ;
56- _nslog = null ;
5754 Directory . Delete ( _logDirectory , true ) ;
5855 }
5956
6057 [ Test ]
61- public void TestWithCompositeLogFactory ( ) {
58+ public void TestTwoFileLogs ( )
59+ {
60+ FileLogFactory flf = CreateFileLogFactory ( ) ;
61+ NonSessionLog nslog = new ( flf ) ;
62+ nslog . OnEvent ( "log1" ) ;
63+
64+ NonSessionLog nslog2 = new ( flf ) ;
65+ nslog2 . OnEvent ( "log2" ) ;
66+
67+ // cleanup (don't delete log unless success)
68+ Directory . Delete ( _logDirectory , true ) ;
69+ }
70+
71+ [ Test ]
72+ public void TestWithCompositeLogFactory ( )
73+ {
6274 CompositeLogFactory clf = new CompositeLogFactory ( [ CreateFileLogFactory ( ) , new NullLogFactory ( ) ] ) ;
63- _nslog = new NonSessionLog ( clf ) ;
75+ NonSessionLog nslog = new ( clf ) ;
6476
6577 // Log artifact not created before first log-write
6678 Assert . That ( Directory . Exists ( _logDirectory ) , Is . False ) ;
6779
6880 // Log artifact exists after first log-write
69- _nslog . OnEvent ( "some text" ) ;
81+ nslog . OnEvent ( "some text" ) ;
7082 Assert . That ( Directory . Exists ( _logDirectory ) ) ;
7183 Assert . That ( File . Exists ( Path . Combine ( _logDirectory , "Non-Session-Log.event.current.log" ) ) ) ;
7284
7385 // cleanup (don't delete log unless success)
74- _nslog . Dispose ( ) ;
75- _nslog = null ;
7686 Directory . Delete ( _logDirectory , true ) ;
7787 }
7888}
0 commit comments