Permalink
Browse files

Fixed a bug in MessageRetryTracker.cs causing it to always return false

  • Loading branch information...
1 parent 40422a8 commit 2d8a4de6a18d92516e25782757bfe74c45ddfc22 @mouk mouk committed with phatboyg Mar 31, 2011
@@ -131,6 +131,7 @@
<Compile Include="Load\Sagas\FirstSaga.cs" />
<Compile Include="MessageContext_Specs.cs" />
<Compile Include="MessageInterceptor_Specs.cs" />
+ <Compile Include="MessageRetryTracker_Specs.cs" />
<Compile Include="Performance\EndpointLoadTest.cs" />
<Compile Include="Performance\LoadedRequest.cs" />
<Compile Include="Performance\LoadedResponse.cs" />
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MassTransit.Transports;
+using NUnit.Framework;
+
+namespace MassTransit.Tests
+{
+ [TestFixture]
+ public class MessageRetryTracker_Specs
+ {
+ [Test]
+ public void IsLimitExceeded_return_false_untill_specified_limit_reached()
+ {
+ const int retryLimit = 5;
+
+ var tracker = new MessageRetryTracker(retryLimit);
+ const string id = "qelofjsw";
+
+ for (int i = 0; i < retryLimit; i++)
+ {
+ Assert.IsFalse(tracker.IsRetryLimitExceeded(id));
+ tracker.IncrementRetryCount(id);
+ }
+ Assert.IsTrue(tracker.IsRetryLimitExceeded(id));
+ }
+ }
+}
@@ -29,7 +29,7 @@ public MessageRetryTracker(int retryLimit)
public bool IsRetryLimitExceeded(string id)
{
int retryCount = 0;
- if (_messages.ReadLock(x => x.TryGetValue(id, out retryCount)))
+ if (!_messages.ReadLock(x => x.TryGetValue(id, out retryCount)))
return false;
return retryCount >= _retryLimit;

0 comments on commit 2d8a4de

Please sign in to comment.