Created
May 26, 2010 07:03
-
-
Save panesofglass/414164 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
| class DetailLoaderProgressTest | |
| { | |
| private List<Fake> _batch; | |
| private IDetailLoader<Fake> _detailLoader; | |
| private SpreadsheetDocument _spreadsheet; | |
| private int _counter; | |
| public DetailLoaderProgressTest() | |
| { | |
| _batch = new List<Fake>(); | |
| var itemLoader = new FakeDetailItemLoader(); | |
| _detailLoader = new DetailLoader<Fake>(itemLoader); | |
| _spreadsheet = new SpreadsheetDocument(); | |
| _counter = 0; | |
| } | |
| [Fact] | |
| public void loader_should_load_items() | |
| { | |
| // Original | |
| _detailLoader.Load(_spreadsheet, _batch.Add); | |
| Assert.True(_batch.Any()); | |
| } | |
| [Fact] | |
| public void loader_should_load_10_items() | |
| { | |
| // Original | |
| _detailLoader.Load(_spreadsheet, _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); | |
| _detailLoader.Load(_spreadsheet, _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); | |
| _detailLoader.Load(_spreadsheet, _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; | |
| _detailLoader.Load(_spreadsheet, _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