My code operates on data which "should" be correct. However during development there are occasions when I obtain invalid data.
When that happens I would like to raise the debug assert and, if user choose to continue, the code would filter out the invalid records and continue to operate on "safe" data.
// assert incorrect data
Debug.Assert(person.Items.All(item => item.IsValid), "Inconsistent data!");
// operate on filtered data
this.ItemViewModels = new ObservableCollection<ItemViewModel>(
person.Items
.Where(i =>item.IsValid) // Use only correct data
.Select(i => new ItemViewModel(lang, i)));
I would like to unit test the code path when I choose to operate on the filtered data.
Question: Is there a way how to get past the assert call in the unit test?
Some equivalent to clicking OK=Continue
in the "Assertion Failed" dialogue?
TIA