From 917ecccaf78111b0aa9920318420d1894139001b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Thu, 1 Sep 2016 22:43:22 +0200 Subject: [PATCH] Added AddWithHistory_Adds_Items_As_Last test --- .../StackHistoryExtensionsTests.cs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/ReactiveHistory.UnitTests/StackHistoryExtensionsTests.cs b/tests/ReactiveHistory.UnitTests/StackHistoryExtensionsTests.cs index a6b4ba9..118583d 100644 --- a/tests/ReactiveHistory.UnitTests/StackHistoryExtensionsTests.cs +++ b/tests/ReactiveHistory.UnitTests/StackHistoryExtensionsTests.cs @@ -27,6 +27,52 @@ namespace ReactiveHistory.UnitTests Assert.Equal(item0, target[0]); } + [Fact] + [Trait("ReactiveHistory", "StackHistoryExtensions")] + public void AddWithHistory_Adds_Items_As_Last() + { + var history = new StackHistory(); + var target = new ObservableCollection(); + var item0 = new Item("item0"); + var item1 = new Item("item1"); + var item2 = new Item("item2"); + + target.AddWithHistory(item0, history); + target.AddWithHistory(item1, history); + target.AddWithHistory(item2, history); + Assert.Equal(3, target.Count); + Assert.Equal(item0, target[0]); + Assert.Equal(item1, target[1]); + Assert.Equal(item2, target[2]); + + history.Undo(); + Assert.Equal(2, target.Count); + Assert.Equal(item0, target[0]); + Assert.Equal(item1, target[1]); + + history.Undo(); + Assert.Equal(1, target.Count); + Assert.Equal(item0, target[0]); + + history.Undo(); + Assert.Equal(0, target.Count); + + history.Redo(); + Assert.Equal(1, target.Count); + Assert.Equal(item0, target[0]); + + history.Redo(); + Assert.Equal(2, target.Count); + Assert.Equal(item0, target[0]); + Assert.Equal(item1, target[1]); + + history.Redo(); + Assert.Equal(3, target.Count); + Assert.Equal(item0, target[0]); + Assert.Equal(item1, target[1]); + Assert.Equal(item2, target[2]); + } + [Fact] [Trait("ReactiveHistory", "StackHistoryExtensions")] public void InsertWithHistory_Inserts_Item_Empty_List()