public void AscendingSort()
        {
            int[] intArr = { 45, 23, 57, 56, 11, 87, 94, 44 };
            SortedBindingList<int> sortedList = new SortedBindingList<int>(intArr);
            sortedList.ListChanged += new ListChangedEventHandler(sortedList_ListChanged);

            Assert.AreEqual(false, sortedList.IsSorted);
            Assert.AreEqual(56, intArr[3]);
            sortedList.ApplySort("", ListSortDirection.Ascending);
            Assert.AreEqual(44, sortedList[2]);
            Assert.AreEqual(8, sortedList.Count);
            Assert.AreEqual(true, sortedList.Contains(56));
            Assert.AreEqual(4, sortedList.IndexOf(56));
            Assert.AreEqual(true, sortedList.IsReadOnly);
            Assert.AreEqual(true, sortedList.IsSorted);

            foreach (int item in sortedList)
            {
                Console.WriteLine(item.ToString());
            }

            sortedList.RemoveSort();
            Assert.AreEqual(false, sortedList.IsSorted);
            Assert.AreEqual(56, sortedList[3]);

            // This list dowes not support searching
            Assert.IsFalse(sortedList.SupportsSearching);
            // and Find should return -1 because underlying list dows not implement IBindingList
            Assert.AreEqual(-1, sortedList.Find("", 56));
        }
        public void AscendingSort()
        {
            int[] intArr = { 45, 23, 57, 56, 11, 87, 94, 44 };
            SortedBindingList <int> sortedList = new SortedBindingList <int>(intArr);

            sortedList.ListChanged += new ListChangedEventHandler(sortedList_ListChanged);

            Assert.AreEqual(false, sortedList.IsSorted);
            Assert.AreEqual(56, intArr[3]);
            sortedList.ApplySort("", ListSortDirection.Ascending);
            Assert.AreEqual(44, sortedList[2]);
            Assert.AreEqual(8, sortedList.Count);
            Assert.AreEqual(true, sortedList.Contains(56));
            Assert.AreEqual(4, sortedList.IndexOf(56));
            Assert.AreEqual(true, sortedList.IsReadOnly);
            Assert.AreEqual(true, sortedList.IsSorted);

            foreach (int item in sortedList)
            {
                Console.WriteLine(item.ToString());
            }

            sortedList.RemoveSort();
            Assert.AreEqual(false, sortedList.IsSorted);
            Assert.AreEqual(56, sortedList[3]);

            // This list dowes not support searching
            Assert.IsFalse(sortedList.SupportsSearching);
            // and Find should return -1 because underlying list dows not implement IBindingList
            Assert.AreEqual(-1, sortedList.Find("", 56));
        }
        public void IndexOf()
        {
            List <string> list = new List <string>();

            string barney  = "Barney";
            string charlie = "Charlie";
            string zeke    = "Zeke";

            list.AddRange(new string[] { charlie, barney, zeke });

            SortedBindingList <string> sortedList = new SortedBindingList <string>(list);

            Assert.AreEqual(1, sortedList.IndexOf(barney), "Unsorted index should be 1");

            sortedList.ApplySort(string.Empty, System.ComponentModel.ListSortDirection.Ascending);

            Assert.AreEqual(1, sortedList.IndexOf(charlie), "Sorted index should be 1");
        }
Exemple #4
0
        public void IndexOfNotFound()
        {
            var cut = new SortedBindingList <Data>();

            AddData(cut, 3);

            var rc = cut.IndexOf(new Data());

            Assert.AreEqual(-1, rc);
        }
Exemple #5
0
        public void IndexOf()
        {
            var cut = new SortedBindingList <Data>();

            var datas = AddData(cut, 3);

            var rc = cut.IndexOf(datas[1]);

            Assert.AreEqual(1, rc);
        }
Exemple #6
0
        public PreguntasEditForm(Pregunta pregunta, SortedBindingList <Pregunta> preguntas, bool ismodal)
            : base(ismodal)
        {
            InitializeComponent();

            Lista           = preguntas;
            _pregunta       = pregunta;
            _copia_pregunta = _pregunta.Clone();
            if (Lista != null)
            {
                SetFormData();
                this.Text = Resources.Labels.PREGUNTA_EDIT_TITLE;
            }
            _mf_type = ManagerFormType.MFEdit;

            int index = Lista.IndexOf(_pregunta);

            EnableButtons(index);
        }
        public void IndexOf()
        {
            List<string> list = new List<string>();

            string barney = "Barney";
            string charlie = "Charlie";
            string zeke = "Zeke";

            list.AddRange(new string[] { charlie, barney, zeke });

            SortedBindingList<string> sortedList = new SortedBindingList<string>(list);

            Assert.AreEqual(1, sortedList.IndexOf(barney), "Unsorted index should be 1");

            sortedList.ApplySort(string.Empty, System.ComponentModel.ListSortDirection.Ascending);

            Assert.AreEqual(1, sortedList.IndexOf(charlie), "Sorted index should be 1");
        }