Skip to content

Instantly share code, notes, and snippets.

@krishnabhargav
Created December 13, 2011 01:53
Show Gist options
  • Save krishnabhargav/1470033 to your computer and use it in GitHub Desktop.
Save krishnabhargav/1470033 to your computer and use it in GitHub Desktop.
Simple Event Throttling Requirement Expressed as a Test
[TestFixture]
public class TestEventThrottling
{
[Test]
public void EventsAreThrottled()
{
var fq = new Frequent();
int counter = 0;
fq.PropertyChanged += (s, e) => { counter++; };
foreach (var prop in Enumerable.Range(0, 200))
fq.Property = prop.ToString();
Thread.Sleep(1000);
Assert.AreEqual(1, counter, "Since throttled at 1/sec");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment