Exemple #1
0
        public void TestDoubleSortByAsc(IEnumerable <StudentTestResult> testResults)
        {
            Sorter <StudentTestResult> sorter        = new Sorter <StudentTestResult>();
            const string propertyName                = "Score";
            const string propertyNameArgument        = "FirstName";
            Type         typeOfArgument              = typeof(string);
            IEnumerable <StudentTestResult> expected = testResults
                                                       .OrderBy(test => test.Score).ThenBy(item => item.FirstName).ToArray();

            sorter.AndSortByAsc <byte>(propertyName);
            sorter.AndSortByAsc(propertyNameArgument, typeOfArgument);
            IEnumerable <StudentTestResult> actual = sorter.ApplySort(testResults).ToArray();

            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
        public void TestAndSortByAsc_TProperty(IEnumerable <StudentTestResult> testResults)
        {
            Sorter <StudentTestResult> sorter        = new Sorter <StudentTestResult>();
            const string propertyName                = "Score";
            IEnumerable <StudentTestResult> expected = testResults
                                                       .OrderBy(test => test.Score).ToArray();

            sorter.AndSortByAsc <byte>(propertyName);
            IEnumerable <StudentTestResult> actual = sorter.ApplySort(testResults).ToArray();

            Assert.AreEqual(expected, actual);
        }
        private void ConstructFirstSortingInfo()
        {
            if (radioButtonAsc.Checked)
            {
                if (comboBox1.Text == "Score")
                {
                    sorter.AndSortByAsc(comboBox1.Text, typeof(int));
                }

                if (comboBox1.Text == "TestDate")
                {
                    sorter.AndSortByAsc(comboBox1.Text, typeof(DateTime));
                }
                else
                {
                    sorter.AndSortByAsc(comboBox1.Text, typeof(string));
                }
            }
            if (radioButtonDesc.Checked)
            {
                if (comboBox1.Text == "Score")
                {
                    sorter.AndSortByDesc(comboBox1.Text, typeof(int));
                }

                if (comboBox1.Text == "TestDate")
                {
                    sorter.AndSortByDesc(comboBox1.Text, typeof(DateTime));
                }
                else
                {
                    sorter.AndSortByDesc(comboBox1.Text, typeof(string));
                }
            }
        }