public void UnreadCount_Test() { var tab = new PublicSearchTabModel("search"); tab.UnreadManage = true; // 未読なし Assert.Equal(0, tab.UnreadCount); tab.AddPostQueue(new PostClass { StatusId = 100L, IsRead = false, // 未読 }); tab.AddSubmit(); Assert.Equal(1, tab.UnreadCount); tab.AddPostQueue(new PostClass { StatusId = 50L, IsRead = true, // 既読 }); tab.AddSubmit(); Assert.Equal(1, tab.UnreadCount); }
public void SelectPosts_Test() { var tab = new PublicSearchTabModel("search"); var posts = new[] { new PostClass { StatusId = 100L }, new PostClass { StatusId = 110L }, new PostClass { StatusId = 120L }, }; tab.AddPostQueue(posts[0]); tab.AddPostQueue(posts[1]); tab.AddPostQueue(posts[2]); tab.AddSubmit(); tab.SelectPosts(new[] { 0, 2 }); Assert.Equal(new[] { 100L, 120L }, tab.SelectedStatusIds); Assert.Equal(100L, tab.SelectedStatusId); Assert.Equal(new[] { posts[0], posts[2] }, tab.SelectedPosts); Assert.Equal(posts[0], tab.SelectedPost); Assert.Equal(0, tab.SelectedIndex); }
public void EnqueueRemovePost_SelectedTest() { var tab = new PublicSearchTabModel("search"); tab.AddPostQueue(new PostClass { StatusId = 100L }); tab.AddPostQueue(new PostClass { StatusId = 110L }); tab.AddSubmit(); tab.SelectPosts(new[] { 0, 1 }); Assert.Equal(2, tab.AllCount); Assert.Equal(new[] { 100L, 110L }, tab.SelectedStatusIds); tab.EnqueueRemovePost(100L, setIsDeleted: false); // この時点では変化しない Assert.Equal(2, tab.AllCount); Assert.Equal(new[] { 100L, 110L }, tab.SelectedStatusIds); tab.RemoveSubmit(); // 削除された発言の選択が解除される Assert.Equal(1, tab.AllCount); Assert.Equal(new[] { 110L }, tab.SelectedStatusIds); }
public void SearchPostsAll_ReverseOrderTest() { var tab = new PublicSearchTabModel("search"); tab.AddPostQueue(new PostClass { StatusId = 100L, TextFromApi = "abcd", ScreenName = "", Nickname = "" }); // 0 tab.AddPostQueue(new PostClass { StatusId = 110L, TextFromApi = "efgh", ScreenName = "", Nickname = "" }); // 1 tab.AddPostQueue(new PostClass { StatusId = 120L, TextFromApi = "ijkl", ScreenName = "", Nickname = "" }); // 2 tab.AddPostQueue(new PostClass { StatusId = 130L, TextFromApi = "abc", ScreenName = "", Nickname = "" }); // 3 tab.AddPostQueue(new PostClass { StatusId = 140L, TextFromApi = "def", ScreenName = "", Nickname = "" }); // 4 tab.SetSortMode(ComparerMode.Id, SortOrder.Ascending); tab.AddSubmit(); // インデックス番号 4 から逆順に開始 → 4, 3, 2, 1, 0 の順に検索 var result = tab.SearchPostsAll(x => x.Contains("a"), startIndex: 4, reverse: true); Assert.Equal(new[] { 3, 0 }, result); // インデックス番号 2 から逆順に開始 → 2, 1, 0, 4, 3 の順に検索 result = tab.SearchPostsAll(x => x.Contains("a"), startIndex: 2, reverse: true); Assert.Equal(new[] { 0, 3 }, result); }
public void EnqueueRemovePost_SetIsDeletedTest() { var tab = new PublicSearchTabModel("search") { UnreadManage = true, }; var post = new PostClass { StatusId = 100L, IsRead = false }; tab.AddPostQueue(post); tab.AddSubmit(); Assert.Equal(1, tab.AllCount); Assert.Equal(1, tab.UnreadCount); tab.EnqueueRemovePost(100L, setIsDeleted: true); // この時点ではタブからの削除は行われないが、PostClass.IsDeleted は true にセットされる Assert.Equal(1, tab.AllCount); Assert.Equal(1, tab.UnreadCount); Assert.True(post.IsDeleted); var removedIds = tab.RemoveSubmit(); Assert.Equal(0, tab.AllCount); Assert.Equal(0, tab.UnreadCount); Assert.Equal(new[] { 100L }, removedIds.AsEnumerable()); }
public void EnqueueRemovePost_UnknownIdTest() { var tab = new PublicSearchTabModel("search") { UnreadManage = true, }; tab.AddPostQueue(new PostClass { StatusId = 100L, IsRead = false }); tab.AddSubmit(); Assert.Equal(1, tab.AllCount); Assert.Equal(1, tab.UnreadCount); // StatusId = 999L は存在しない tab.EnqueueRemovePost(999L, setIsDeleted: false); Assert.Equal(1, tab.AllCount); Assert.Equal(1, tab.UnreadCount); var removedIds = tab.RemoveSubmit(); Assert.Equal(1, tab.AllCount); Assert.Equal(1, tab.UnreadCount); Assert.Empty(removedIds); }
public void EnqueueRemovePost_Test() { var tab = new PublicSearchTabModel("search") { UnreadManage = true, }; tab.AddPostQueue(new PostClass { StatusId = 100L, IsRead = false }); tab.AddPostQueue(new PostClass { StatusId = 110L, IsRead = false }); tab.AddPostQueue(new PostClass { StatusId = 120L, IsRead = false }); tab.AddSubmit(); Assert.Equal(3, tab.AllCount); Assert.Equal(3, tab.UnreadCount); tab.EnqueueRemovePost(100L, setIsDeleted: false); // この時点では削除は行われない Assert.Equal(3, tab.AllCount); Assert.Equal(3, tab.UnreadCount); var removedIds = tab.RemoveSubmit(); Assert.Equal(2, tab.AllCount); Assert.Equal(2, tab.UnreadCount); Assert.Equal(new[] { 110L, 120L }, tab.StatusIds); Assert.Equal(new[] { 100L }, removedIds.AsEnumerable()); }
public void GetterSlice_ErrorTest() { var tab = new PublicSearchTabModel("search"); tab.AddPostQueue(new PostClass { StatusId = 100L, TextFromApi = "abcd" }); // 0 tab.AddPostQueue(new PostClass { StatusId = 110L, TextFromApi = "efgh" }); // 1 tab.AddPostQueue(new PostClass { StatusId = 120L, TextFromApi = "ijkl" }); // 2 tab.SetSortMode(ComparerMode.Id, SortOrder.Ascending); tab.AddSubmit(); Assert.Throws <ArgumentOutOfRangeException>(() => tab[-2, -1]); // 範囲外 ... 範囲外 Assert.Throws <ArgumentOutOfRangeException>(() => tab[-1, 1]); // 範囲外 ... 範囲内 Assert.Throws <ArgumentOutOfRangeException>(() => tab[2, 3]); // 範囲内 ... 範囲外 Assert.Throws <ArgumentOutOfRangeException>(() => tab[3, 4]); // 範囲外 ... 範囲外 Assert.Throws <ArgumentOutOfRangeException>(() => tab[-1, 3]); // 範囲外 ... 範囲外 Assert.Throws <ArgumentException>(() => tab[2, 0]); // 範囲内だが startIndex > endIndex }
public void NextUnreadIndex_Test() { var tab = new PublicSearchTabModel("search"); tab.SetSortMode(ComparerMode.Id, SortOrder.Ascending); tab.UnreadManage = true; // 未読なし Assert.Equal(-1, tab.NextUnreadIndex); tab.AddPostQueue(new PostClass { StatusId = 50L, IsRead = true, // 既読 }); tab.AddPostQueue(new PostClass { StatusId = 100L, IsRead = false, // 未読 }); tab.AddPostQueue(new PostClass { StatusId = 150L, IsRead = false, // 未読 }); tab.AddSubmit(); Assert.Equal(1, tab.NextUnreadIndex); }
public void Getter_Test() { var tabs = new TabCollection(); var tab = new PublicSearchTabModel("hoge"); tabs.Add(tab); Assert.Equal(tab, tabs["hoge"]); }
public void IndexOf_TabName_Test() { var tabs = new TabCollection(); var tab1 = new PublicSearchTabModel("aaaaa"); var tab2 = new PublicSearchTabModel("bbbbb"); tabs.Add(tab1); tabs.Add(tab2); Assert.Equal(1, tabs.IndexOf("bbbbb")); }
public void TryGetValue_TabName_Test() { var tabs = new TabCollection(); var tab1 = new PublicSearchTabModel("aaaaa"); var tab2 = new PublicSearchTabModel("bbbbb"); tabs.Add(tab1); tabs.Add(tab2); Assert.True(tabs.TryGetValue("bbbbb", out var actualTab)); Assert.Equal(tab2, actualTab); }
public void SelectPosts_InvalidIndexTest() { var tab = new PublicSearchTabModel("search"); tab.AddPostQueue(new PostClass { StatusId = 100L }); tab.AddSubmit(); Assert.Throws <ArgumentOutOfRangeException>(() => tab.SelectPosts(new[] { -1 })); Assert.Throws <ArgumentOutOfRangeException>(() => tab.SelectPosts(new[] { 1 })); }
public void SetReadAllTab_MarkAsUnreadTest() { var tab1 = new PublicSearchTabModel("search1"); var tab2 = new PublicSearchTabModel("search2"); this.tabinfo.AddTab(tab1); this.tabinfo.AddTab(tab2); // search1 に追加するツイート (StatusId: 100, 150, 200; すべて既読) tab1.UnreadManage = true; tab1.AddPostQueue(new PostClass { StatusId = 100L, IsRead = true }); tab1.AddPostQueue(new PostClass { StatusId = 150L, IsRead = true }); tab1.AddPostQueue(new PostClass { StatusId = 200L, IsRead = true }); // search2 に追加するツイート (StatusId: 150, 200, 250; すべて既読) tab2.UnreadManage = true; tab2.AddPostQueue(new PostClass { StatusId = 150L, IsRead = true }); tab2.AddPostQueue(new PostClass { StatusId = 200L, IsRead = true }); tab2.AddPostQueue(new PostClass { StatusId = 250L, IsRead = true }); this.tabinfo.DistributePosts(); this.tabinfo.SubmitUpdate(); // この時点での各タブの未読件数 Assert.Equal(0, tab1.UnreadCount); Assert.Equal(0, tab2.UnreadCount); // ... ここまで長い前置き // StatusId: 200 を未読にする (search1, search2 両方に含まれる) this.tabinfo.SetReadAllTab(200L, read: false); Assert.Equal(1, tab1.UnreadCount); Assert.Equal(1, tab2.UnreadCount); // StatusId: 100 を未読にする (search1 のみに含まれる) this.tabinfo.SetReadAllTab(100L, read: false); Assert.Equal(2, tab1.UnreadCount); Assert.Equal(1, tab2.UnreadCount); }
public void UnreadCount_DisabledTest() { var tab = new PublicSearchTabModel("search"); // 未読表示無効 tab.UnreadManage = false; tab.AddPostQueue(new PostClass { StatusId = 100L, IsRead = false, // 未読 }); tab.AddSubmit(); Assert.Equal(0, tab.UnreadCount); }
public void SelectPosts_EmptyTest() { var tab = new PublicSearchTabModel("search"); tab.AddPostQueue(new PostClass { StatusId = 100L }); tab.AddSubmit(); tab.SelectPosts(Array.Empty <int>()); Assert.Empty(tab.SelectedStatusIds); Assert.Equal(-1L, tab.SelectedStatusId); Assert.Empty(tab.SelectedPosts); Assert.Null(tab.SelectedPost); Assert.Equal(-1, tab.SelectedIndex); }
public void SetReadState_MarkAsUnreadTest() { var tab = new PublicSearchTabModel("search"); tab.UnreadManage = true; tab.AddPostQueue(new PostClass { StatusId = 100L, IsRead = true, // 既読 }); tab.AddSubmit(); Assert.Equal(0, tab.UnreadCount); tab.SetReadState(100L, false); // 未読にする Assert.Equal(1, tab.UnreadCount); }
public void GetterSingle_Test() { var tab = new PublicSearchTabModel("search"); tab.AddPostQueue(new PostClass { StatusId = 100L, TextFromApi = "abcd" }); // 0 tab.AddPostQueue(new PostClass { StatusId = 110L, TextFromApi = "efgh" }); // 1 tab.AddPostQueue(new PostClass { StatusId = 120L, TextFromApi = "ijkl" }); // 2 tab.SetSortMode(ComparerMode.Id, SortOrder.Ascending); tab.AddSubmit(); Assert.Equal(100L, tab[0].StatusId); Assert.Equal(120L, tab[2].StatusId); }
public void GetUnreadIds_Test() { var tab = new PublicSearchTabModel("search"); tab.UnreadManage = true; Assert.Empty(tab.GetUnreadIds()); tab.AddPostQueue(new PostClass { StatusId = 100L, IsRead = false }); tab.AddPostQueue(new PostClass { StatusId = 200L, IsRead = true }); tab.AddSubmit(); Assert.Equal(new[] { 100L }, tab.GetUnreadIds()); tab.SetReadState(100L, true); // 既読にする Assert.Empty(tab.GetUnreadIds()); }
public void NextUnreadId_SortByScreenNameDescTest() { var tab = new PublicSearchTabModel("search"); tab.UnreadManage = true; // ScreenName の降順でソート tab.SetSortMode(ComparerMode.Name, SortOrder.Descending); // 画面には上から 300 → 100 → 200 の順に並ぶ tab.AddPostQueue(new PostClass { StatusId = 100L, ScreenName = "bbb", IsRead = false }); tab.AddPostQueue(new PostClass { StatusId = 200L, ScreenName = "aaa", IsRead = false }); tab.AddPostQueue(new PostClass { StatusId = 300L, ScreenName = "ccc", IsRead = false }); tab.AddSubmit(); // 昇順/降順に関わらず、ScreenName の辞書順で小さい順に未読の ID を返す Assert.Equal(200L, tab.NextUnreadId); }
public void NextUnreadId_SortByIdDescTest() { var tab = new PublicSearchTabModel("search"); tab.UnreadManage = true; // ID の降順でソート tab.SetSortMode(ComparerMode.Id, SortOrder.Descending); // 画面には上から 300 → 200 → 100 の順に並ぶ tab.AddPostQueue(new PostClass { StatusId = 100L, IsRead = false }); tab.AddPostQueue(new PostClass { StatusId = 200L, IsRead = false }); tab.AddPostQueue(new PostClass { StatusId = 300L, IsRead = false }); tab.AddSubmit(); // 昇順/降順に関わらず、ID の小さい順に未読の ID を返す Assert.Equal(100L, tab.NextUnreadId); }