Ejemplo n.º 1
0
        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);
        }