Skip to content

Commit

Permalink
Fixed duration test.
Browse files Browse the repository at this point in the history
Turns out it was an unmanifested projection causing the problem.
  • Loading branch information
mitchdenny committed Dec 3, 2012
1 parent c6a2d44 commit b9db635
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
15 changes: 6 additions & 9 deletions Palmer.Tests/RetryTests.cs
Expand Up @@ -58,7 +58,6 @@ public void GivenInvalidUrlWebExceptionRaisedAndSelectedByPredicate()
}

[TestMethod]
[Ignore]
public void GivenInvalidUrlWebExceptionGivesUpAfter15Seconds()
{
var stopwatch = new Stopwatch();
Expand All @@ -72,16 +71,14 @@ public void GivenInvalidUrlWebExceptionGivesUpAfter15Seconds()
client.DownloadData(invalidUrl);
});
}
catch
catch(RetryException ex)
{
stopwatch.Stop();
// Hard to truly test this, but you would think with execution overheads
// that if you tell it to wait for ten seconds before giving up that
// the total execution time would be slightly more than ten seconds.
Assert.IsTrue(stopwatch.Elapsed > TimeSpan.FromSeconds(15), "Stop watch elapsed time exceeded allotted time.", stopwatch.Elapsed);
}

stopwatch.Stop();

// Hard to truly test this, but you would think with execution overheads
// that if you tell it to wait for ten seconds before giving up that
// the total execution time would be slightly more than ten seconds.
Assert.IsTrue(stopwatch.Elapsed > TimeSpan.FromSeconds(15), "Stop watch elapsed time exceeded allotted time.", stopwatch.Elapsed);
}
}
}
3 changes: 3 additions & 0 deletions Palmer/RetryConditionHandle.cs
@@ -1,12 +1,15 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace Palmer
{
public class RetryConditionHandle
{
private static Random m_Generator = new Random();

public RetryConditionHandle(RetryContext context, RetryCondition condition)
{
Context = context;
Expand Down
3 changes: 1 addition & 2 deletions Palmer/RetryContext.cs
Expand Up @@ -11,8 +11,7 @@ public class RetryContext
public RetryContext(Retry retry)
{
Retry = retry;
ConditionHandles = retry.Conditions.Select(condition => new RetryConditionHandle(this, condition));
Started = DateTimeOffset.Now;
ConditionHandles = retry.Conditions.Select(condition => new RetryConditionHandle(this, condition)).ToList();
}

public IEnumerable<RetryConditionHandle> ConditionHandles { get; private set; }
Expand Down

0 comments on commit b9db635

Please sign in to comment.