예제 #1
0
        public void TestWorkWithEmptyFilter(IEnumerable <StudentTestResult> expected)
        {
            Sorter <StudentTestResult> sorter = new Sorter <StudentTestResult>();

            IEnumerable <StudentTestResult> actual = sorter.ApplySort(expected);

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void TestWorkWithEmptyCollection(IEnumerable <StudentTestResult> testResults)
        {
            Sorter <StudentTestResult> Sorter = new Sorter <StudentTestResult>();

            void TryApplySorter()
            {
                IEnumerable <StudentTestResult> result = Sorter.ApplySort(testResults);
            }

            Assert.Throws(typeof(InvalidOperationException), TryApplySorter);
        }
예제 #3
0
        public void TestWorkWithNullCollection(IEnumerable <StudentTestResult> testResults)
        {
            Sorter <StudentTestResult> Sorter = new Sorter <StudentTestResult>();

            void TryApplySorter()
            {
                IEnumerable <StudentTestResult> result = Sorter.ApplySort(testResults);
            }

            Assert.Throws(typeof(ArgumentNullException), TryApplySorter);
        }
예제 #4
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);
        }
예제 #5
0
        private void ApplyExistingConditions()
        {
            IEnumerable<StudentTestResult> buffer = new List<StudentTestResult>(filter.ApplyFilterSettings(studentTestResults));
            buffer = sorter.ApplySort(buffer);

            if (checkBoxOnlyTake.Checked)
            {
                buffer = buffer.Take((int)numericUpDown1.Value);
            }

            visibleStudentsTestsResults = new List<StudentTestResult>(buffer);
        }
예제 #6
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);
        }