33using System ;
44using System . Collections . Generic ;
55using System . IO ;
6-
7- using EasyNetQ . Consumer ;
8-
96using Xunit ;
107
118namespace EasyNetQ . Hosepipe . Tests
@@ -19,7 +16,6 @@ public class ProgramTests
1916 private MockQueueInsertion queueInsertion ;
2017 private MockErrorRetry errorRetry ;
2118 private Conventions conventions ;
22- private IErrorMessageSerializer defaultErrorMessageSerializer ;
2319
2420 public ProgramTests ( )
2521 {
@@ -29,7 +25,6 @@ public ProgramTests()
2925 queueInsertion = new MockQueueInsertion ( ) ;
3026 errorRetry = new MockErrorRetry ( ) ;
3127 conventions = new Conventions ( new LegacyTypeNameSerializer ( ) ) ;
32- defaultErrorMessageSerializer = new DefaultErrorMessageSerializer ( ) ;
3328
3429 program = new Program (
3530 new ArgParser ( ) ,
@@ -38,11 +33,12 @@ public ProgramTests()
3833 messageReader ,
3934 queueInsertion ,
4035 errorRetry ,
41- conventions ) ;
36+ conventions
37+ ) ;
4238 }
4339
4440 private readonly string expectedDumpOutput =
45- "2 Messages from queue 'EasyNetQ_Default_Error_Queue'\r \n output to directory '" + Directory . GetCurrentDirectory ( ) + "' \r \n ";
41+ $ "2 messages from queue 'EasyNetQ_Default_Error_Queue' were dumped to directory '{ Directory . GetCurrentDirectory ( ) } ' { Environment . NewLine } ";
4642
4743 [ Fact ]
4844 public void Should_output_messages_to_directory_with_dump ( )
@@ -59,14 +55,15 @@ public void Should_output_messages_to_directory_with_dump()
5955
6056 program . Start ( args ) ;
6157
62- writer . GetStringBuilder ( ) . ToString ( ) . ShouldEqual ( expectedDumpOutput ) ;
58+ var actualOutput = writer . GetStringBuilder ( ) . ToString ( ) ;
59+ actualOutput . ShouldEqual ( expectedDumpOutput ) ;
6360
6461 messageWriter . Parameters . QueueName . ShouldEqual ( "EasyNetQ_Default_Error_Queue" ) ;
6562 messageWriter . Parameters . HostName . ShouldEqual ( "localhost" ) ;
6663 }
6764
6865 private readonly string expectedInsertOutput =
69- "2 Messages from directory '" + Directory . GetCurrentDirectory ( ) + "' \r \n inserted into queue ''\r \n ";
66+ $ " { 2 } messages from directory '{ Directory . GetCurrentDirectory ( ) } ' were inserted into queue ''{ Environment . NewLine } ";
7067
7168 [ Fact ]
7269 public void Should_insert_messages_with_insert ( )
@@ -82,13 +79,38 @@ public void Should_insert_messages_with_insert()
8279
8380 program . Start ( args ) ;
8481
85- writer . GetStringBuilder ( ) . ToString ( ) . ShouldEqual ( expectedInsertOutput ) ;
82+ var actualInsertOutput = writer . GetStringBuilder ( ) . ToString ( ) ;
83+ actualInsertOutput . ShouldEqual ( expectedInsertOutput ) ;
84+
85+ messageReader . Parameters . HostName . ShouldEqual ( "localhost" ) ;
86+ }
87+
88+ private readonly string expectedInsertOutputWithQueue =
89+ $ "{ 2 } messages from directory '{ Directory . GetCurrentDirectory ( ) } ' were inserted into queue 'queue'{ Environment . NewLine } ";
90+
91+ [ Fact ]
92+ public void Should_insert_messages_with_insert_and_queue ( )
93+ {
94+ var args = new [ ]
95+ {
96+ "insert" ,
97+ "s:localhost" ,
98+ "q:queue"
99+ } ;
100+
101+ var writer = new StringWriter ( ) ;
102+ Console . SetOut ( writer ) ;
103+
104+ program . Start ( args ) ;
105+
106+ var actualInsertOutput = writer . GetStringBuilder ( ) . ToString ( ) ;
107+ actualInsertOutput . ShouldEqual ( expectedInsertOutputWithQueue ) ;
86108
87109 messageReader . Parameters . HostName . ShouldEqual ( "localhost" ) ;
88110 }
89111
90112 private readonly string expectedRetryOutput =
91- "2 Error messages from directory '" + Directory . GetCurrentDirectory ( ) + "' republished\r \n ";
113+ $ "2 error messages from directory '{ Directory . GetCurrentDirectory ( ) } ' were republished{ Environment . NewLine } ";
92114
93115
94116 [ Fact ]
@@ -118,14 +140,13 @@ public class MockMessageWriter : IMessageWriter
118140 public void Write ( IEnumerable < HosepipeMessage > messages , QueueParameters queueParameters )
119141 {
120142 Parameters = queueParameters ;
121- foreach ( var message in messages )
143+ foreach ( var _ in messages )
122144 {
123- // Console.Out.WriteLine("message = {0}", message);
124145 }
125146 }
126147 }
127148
128- public class MockQueueRetrieval : IQueueRetreival
149+ public class MockQueueRetrieval : IQueueRetrieval
129150 {
130151 public IEnumerable < HosepipeMessage > GetMessagesFromQueue ( QueueParameters parameters )
131152 {
@@ -155,9 +176,8 @@ public class MockQueueInsertion : IQueueInsertion
155176 {
156177 public void PublishMessagesToQueue ( IEnumerable < HosepipeMessage > messages , QueueParameters parameters )
157178 {
158- foreach ( var message in messages )
179+ foreach ( var _ in messages )
159180 {
160- // Console.Out.WriteLine("message = {0}", message);
161181 }
162182 }
163183 }
@@ -166,12 +186,11 @@ public class MockErrorRetry : IErrorRetry
166186 {
167187 public void RetryErrors ( IEnumerable < HosepipeMessage > rawErrorMessages , QueueParameters parameters )
168188 {
169- foreach ( var rawErrorMessage in rawErrorMessages )
189+ foreach ( var _ in rawErrorMessages )
170190 {
171- //
172191 }
173192 }
174193 }
175194}
176195
177- // ReSharper restore InconsistentNaming
196+ // ReSharper restore InconsistentNaming
0 commit comments