public void Can_overflow_limited_history() { //arrange var history = new HistoryBuffer <string>(maxSize: 2); string currentItem = null, previousItem = null; history.HistoryOverflowed += delegate(object sender, HistoryEventArgs <string> args) { args.TryGetCurrentItem(out currentItem); args.TryGetPreviousItem(out previousItem); }; //act history.RememberNew("first item"); history.RememberNew("second item"); history.RememberNew("third item"); //assert currentItem.Should().Be("third item"); previousItem.Should().Be("second item"); history.GetAll().ToArray().Should().BeEquivalentTo(new[] { "second item", "third item" }); }
public void Can_clear_history() { //arrange var history = new HistoryBuffer <string>(maxSize: 2); //act history.RememberNew("first item"); history.RememberNew("second item"); history.RememberNew("third item"); history.Clear(); //assert history.Count.Should().Be(0); history.GetAll().ToArray().Should().BeEmpty(); }