Created
May 26, 2010 06:28
-
-
Save panesofglass/414141 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DetailLoaderProgressTest | |
| { | |
| private List<Fake> _batch; | |
| private IDetailLoader<Fake> _detailLoader; | |
| private int _counter; | |
| public DetailLoaderProgressTest() | |
| { | |
| _batch = new List<Fake>(); | |
| _detailLoader = new FakeDetailLoader(); | |
| _counter = 0; | |
| } | |
| [Fact] | |
| public void loader_should_load_items() | |
| { | |
| // Original | |
| _detailLoader.Load(string.Empty, _batch.Add); | |
| Assert.True(_batch.Any()); | |
| } | |
| [Fact] | |
| public void loader_should_load_10_items() | |
| { | |
| // Original | |
| _detailLoader.Load(string.Empty, _batch.Add); | |
| Assert.Equal(10, _batch.Count); | |
| } | |
| [Fact] | |
| public void loader_with_decorator_should_load_items() | |
| { | |
| // Original | |
| var progressItem = new ProgressItem(); | |
| progressItem.Start(10); | |
| var decoratedLoader = new DetailLoaderWithProgressItem<Fake>(_detailLoader, progressItem); | |
| decoratedLoader.Load(string.Empty, _batch.Add); | |
| Assert.True(_batch.Any()); | |
| } | |
| [Fact] | |
| public void loader_with_decorator_should_load_10_items() | |
| { | |
| // Original | |
| var progressItem = new ProgressItem(); | |
| progressItem.Start(10); | |
| var decoratedLoader = new DetailLoaderWithProgressItem<Fake>(_detailLoader, progressItem); | |
| decoratedLoader.Load(string.Empty, _batch.Add); | |
| Assert.Equal(10, _batch.Count); | |
| } | |
| [Fact] | |
| public void loader_with_decorator_should_report_10_events() | |
| { | |
| // Important, but missed this one! | |
| var progressItem = new ProgressItem(); | |
| progressItem.Start(10); | |
| var decoratedLoader = new DetailLoaderWithProgressItem<Fake>(_detailLoader, progressItem); | |
| progressItem.PropertyChanged += OnProgressItemChanged; | |
| decoratedLoader.Load(string.Empty, _batch.Add); | |
| Assert.Equal(10, _counter); | |
| progressItem.PropertyChanged -= OnProgressItemChanged; | |
| } | |
| void OnProgressItemChanged(object sender, PropertyChangedEventArgs e) | |
| { | |
| _counter++; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment