2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Collections.Generic;
21 namespace ElmSharp.Test
23 class GenListTest11 : TestCaseBase
25 public override string TestName => "GenListTest11";
26 public override string TestDescription => "To test InsertSorted operation of GenList";
28 public int myCompare(object t1, object t2)
30 int c1 = Convert.ToInt32((string)t1);
31 int c2 = Convert.ToInt32((string)t2);
36 public override void Run(Window window)
38 Conformant conformant = new Conformant(window);
40 Box box = new Box(window)
48 conformant.SetContent(box);
50 GenList list = new GenList(window)
59 GenItemClass defaultClass = new GenItemClass("default")
61 GetTextHandler = (obj, part) =>
63 return string.Format("{0} - {1}", (string)obj, part);
67 List<GenListItem> items = new List<GenListItem>();
69 for (int t = 1; t < 10; t++)
71 items.Add(list.InsertSorted(defaultClass, idx.ToString(), myCompare, GenListItemType.Normal, null));
75 list.ItemSelected += List_ItemSelected;
78 Button first = new Button(window)
80 Text = "Check first and last item",
85 Button Add = new Button(window)
91 Add.Clicked += (s, e) =>
93 items.Add(list.InsertSorted(defaultClass, idx.ToString(), myCompare, GenListItemType.Normal, null));
97 first.Clicked += (s, e) =>
99 Console.WriteLine("Last Item's Data : " + list.LastItem.Data);
100 Console.WriteLine("First date of Items " + items[0].Data);
101 Console.WriteLine("Result for comparinson " + (bool)(list.LastItem == list.LastItem));
110 private void List_ItemSelected(object sender, GenListItemEventArgs e)
112 Console.WriteLine("{0} Item was selected", (string)(e.Item.Data));