private void ConfigureCondition()
        {
            filter.RemoveAllFilters();
            dataGridViewFilterConditions.Rows.Clear();

            object propertyValueA;
            object propertyValueB;
            string propertyName;
            foreach (FilterConditionUserControl condition in filterConditionsList.FilterConditions)
            {
                if (condition.Operation == nameof(Operations.EqualTo))
                {
                    propertyName = GetProperty(condition, out propertyValueA);
                    filter.AndEqualTo(propertyName, propertyValueA);
                }
                if (condition.Operation == nameof(Operations.GreaterThan))
                {
                    propertyName = GetProperty(condition, out propertyValueA);
                    filter.AndGreaterThan(propertyName, propertyValueA);
                }
                if (condition.Operation == nameof(Operations.GreaterTHanOrEqual))
                {
                    propertyName = GetProperty(condition, out propertyValueA);
                    filter.AndGreaterThanOrEqual(propertyName, propertyValueA);
                }
                if (condition.Operation == nameof(Operations.LessThan))
                {
                    propertyName = GetProperty(condition, out propertyValueA);
                    filter.AndLessThan(propertyName, propertyValueA);
                }
                if (condition.Operation == nameof(Operations.LessThanOrEqual))
                {
                    propertyName = GetProperty(condition, out propertyValueA);
                    filter.AndLessThanOrEqual(propertyName, propertyValueA);
                }
                if (condition.Operation == nameof(Operations.Contains))
                {
                    propertyName = GetProperty(condition, out propertyValueA);
                    filter.AndContains(propertyName, (string)propertyValueA);
                }
                if (condition.Operation == nameof(Operations.IsMatch))
                {
                    propertyName = GetProperty(condition, out propertyValueA);
                    filter.AndIsMatch(propertyName, new Regex((string)propertyValueA));
                }
                if (condition.Operation == nameof(Operations.IntoRange))
                {
                    propertyName = GetProperty(condition, out propertyValueA, out propertyValueB);
                    filter.AndIntoRange(propertyName, propertyValueA, propertyValueB);
                }

                UpdateVisualization(condition);
            }
        }
Beispiel #2
0
        public void TestDateTimeAndEqualTo(IEnumerable <StudentTestResult> testResults)
        {
            Filter <StudentTestResult> filters       = new Filter <StudentTestResult>();
            const string propertyName                = "TestDate";
            DateTime     propertyValue               = new DateTime(2021, 02, 04);
            IEnumerable <StudentTestResult> expected = testResults
                                                       .Where(test => test.TestDate == propertyValue).ToArray();

            filters.AndEqualTo(propertyName, propertyValue);
            IEnumerable <StudentTestResult> actual = filters.ApplyFilterSettings(testResults).ToArray();

            Assert.AreEqual(expected, actual);
        }
Beispiel #3
0
        public void TestStringAndEqualTo(IEnumerable <StudentTestResult> testResults)
        {
            Filter <StudentTestResult> filters       = new Filter <StudentTestResult>();
            const string propertyName                = "FirstName";
            const string propertyValue               = "ivan";
            IEnumerable <StudentTestResult> expected = testResults
                                                       .Where(test => test.FirstName == propertyValue).ToArray();

            filters.AndEqualTo(propertyName, propertyValue);
            IEnumerable <StudentTestResult> actual = filters.ApplyFilterSettings(testResults).ToArray();

            Assert.AreEqual(expected, actual);
        }