1 // OpenTween - Client of Twitter
2 // Copyright (c) 2024 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
3 // All rights reserved.
5 // This file is part of OpenTween.
7 // This program is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by the Free
9 // Software Foundation; either version 3 of the License, or (at your option)
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 // You should have received a copy of the GNU General Public License along
18 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
19 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20 // Boston, MA 02110-1301, USA.
24 namespace OpenTween.Models
26 public class StatusTextHistoryTest
29 public void Initialize_Test()
31 var history = new StatusTextHistory();
32 Assert.Single(history.Items);
33 Assert.Equal(new("", null), history.Items[0]);
34 Assert.Equal(0, history.HistoryIndex);
38 public void Back_NoItemsTest()
40 var history = new StatusTextHistory();
41 history.Back("@hoge aaa", (new TwitterStatusId("111"), "hoge"));
42 Assert.Single(history.Items);
43 Assert.Equal(new("@hoge aaa", (new TwitterStatusId("111"), "hoge")), history.Items[0]);
44 Assert.Equal(0, history.HistoryIndex);
48 public void Back_HasItemsTest()
50 var history = new StatusTextHistory();
51 history.SetLastItem("@hoge aaa", (new TwitterStatusId("111"), "hoge"));
53 history.Back("@foo bbb", (new TwitterStatusId("222"), "foo"));
55 Assert.Equal(2, history.Items.Count);
56 Assert.Equal(new("@hoge aaa", (new TwitterStatusId("111"), "hoge")), history.Items[0]);
57 Assert.Equal(new("@foo bbb", (new TwitterStatusId("222"), "foo")), history.Items[1]);
58 Assert.Equal(0, history.HistoryIndex);
62 public void Forward_NoItemsTest()
64 var history = new StatusTextHistory();
65 history.Forward("@hoge aaa", (new TwitterStatusId("111"), "hoge"));
66 Assert.Single(history.Items);
67 Assert.Equal(new("@hoge aaa", (new TwitterStatusId("111"), "hoge")), history.Items[0]);
68 Assert.Equal(0, history.HistoryIndex);
72 public void Forward_HasItemsTest()
74 var history = new StatusTextHistory();
75 history.SetLastItem("@hoge aaa", (new TwitterStatusId("111"), "hoge"));
77 history.Back("@foo bbb", (new TwitterStatusId("222"), "foo"));
78 history.Forward("@hoge aaa 123", (new TwitterStatusId("111"), "hoge"));
80 Assert.Equal(2, history.Items.Count);
81 Assert.Equal(new("@hoge aaa 123", (new TwitterStatusId("111"), "hoge")), history.Items[0]);
82 Assert.Equal(new("@foo bbb", (new TwitterStatusId("222"), "foo")), history.Items[1]);
83 Assert.Equal(1, history.HistoryIndex);
87 public void AddLast_Test()
89 var history = new StatusTextHistory();
90 history.SetLastItem("@hoge aaa", (new TwitterStatusId("111"), "hoge"));
92 Assert.Equal(2, history.Items.Count);
93 Assert.Equal(new("@hoge aaa", (new TwitterStatusId("111"), "hoge")), history.Items[0]);
94 Assert.Equal(new("", null), history.Items[1]);
95 Assert.Equal(1, history.HistoryIndex);
99 public void Peek_EmptyTest()
101 var history = new StatusTextHistory();
102 Assert.Null(history.Peek());
106 public void Peek_HasItemsTest()
108 var history = new StatusTextHistory();
109 history.SetLastItem("@hoge aaa", (new TwitterStatusId("111"), "hoge"));
112 Assert.Equal(new("@hoge aaa", (new TwitterStatusId("111"), "hoge")), history.Peek());