public void Can_repeat() { //arrange var history = new HistoryBuffer <string>(); string currentItem = null, previousItem = null; history.HistoryRepeated += delegate(object sender, HistoryEventArgs <string> args) { args.TryGetCurrentItem(out currentItem); args.TryGetPreviousItem(out previousItem); }; //act history.RememberNew("first item"); history.RememberNew("second item"); history.Undo(); history.Repeat(); //assert currentItem.Should().Be("second item"); previousItem.Should().Be("first item"); history.CurrentItem.Should().Be("second item"); history.Count.Should().Be(2); }
public void Should_remove_obsolete_items_after_adding_new_one() { //arrange var history = new HistoryBuffer <string>(); //act history.RememberNew("first item"); history.RememberNew("second item"); history.Undo(); history.RememberNew("third item"); //assert history.CurrentItem.Should().Be("third item"); history.Count.Should().Be(2); }