public void TestFilterEvaluationFailure()
        {
            FilterCondition parentDirectoryCondition = new FilterCondition(FileMetaAttributesStringConstants.FileMetaAttributeParentDirectory, FileFilterOperator.Equals,
                                                                   @"C:\Projects\Classifier\findfilesutil\Trunk\src\KMPAlgorithmTestRunner\KMPAlgorithmTestRunner\TestData", FilterAttributeDataType.String);
            FilterCondition fileExtensionFilterCondition = new FilterCondition(FileMetaAttributesStringConstants.FileMetaAttributeFileExtension, FileFilterOperator.Equals, "xls", FilterAttributeDataType.String);

            List<FilterCondition> filterConditions = new List<FilterCondition>();
            filterConditions.Add(parentDirectoryCondition);
            filterConditions.Add(fileExtensionFilterCondition);

            //Get information about a test file and then create a dummy filter condition based on the
            //file attribites of the test file

            FileInfo fileInfo = new FileInfo(@"C:\Projects\Classifier\findfilesutil\Trunk\src\KMPAlgorithmTestRunner\KMPAlgorithmTestRunner\TestData\Microsoft.txt");

            FilterCondition fileCreateCondition = new FilterCondition(FileMetaAttributesStringConstants.FileMetaAttributeCreationTime, FileFilterOperator.Equals, fileInfo.CreationTime.Ticks.ToString(), FilterAttributeDataType.Long);
            FileMetaAttributes fileAttributes = new FileMetaAttributes(fileInfo.DirectoryName, fileInfo.CreationTime.Ticks, fileInfo.LastWriteTime.Ticks, fileInfo.Length, fileInfo.Extension, @"HORNET\\prahaladd");

            filterConditions.Add(fileCreateCondition);

            FileMetaAttributeFilter fileFilter = new FileMetaAttributeFilter(filterConditions);

            FileFilterEvaluator filterEvaluator = new FileFilterEvaluator(fileFilter, fileAttributes);

            bool result = filterEvaluator.EvaluateFilter();

            Assert.IsFalse(result);
        }
示例#2
0
 public static bool EvaluateMetaAttributeFilters(FileMetaAttributes fileAttributes, FileMetaAttributeFilter filter)
 {
     FileFilterEvaluator filterEvaluator = new FileFilterEvaluator(filter,fileAttributes);
     return filterEvaluator.EvaluateFilter();
 }