public void DoClear_Should_add_old_elements_When_undone() { ICollection <object> source = new List <object> { new object(), new object(), new object() }; IUnDoManager manager = Substitute.For <IUnDoManager>(); IUnDo undo = null; List <object> sourceCopy = source.ToList(); manager.Do(Arg.Do <IUnDo>(i => undo = i)); manager.DoClear(source); Check.That(undo).IsNotNull(); undo.Do(); Check.That(source.Count).IsEqualTo(0); undo.Undo(); Check.That(source).ContainsExactly(sourceCopy); }
public void DoClear_Should_throw_ArgumentNullException_When_source_is_null() { IUnDoManager manager = Substitute.For <IUnDoManager>(); ICollection <object> source = null; Check .ThatCode(() => manager.DoClear(source)) .Throws <ArgumentNullException>() .WithProperty("ParamName", "source"); }
void ICollection <T> .Clear() => _manager.DoClear(_source, _descriptionFactory?.Invoke(new UnDoCollectionOperation(this, UnDoCollectionAction.ICollectionClear)));