public IEnumerable<ItemType> ProcessOperation(textfilecontent54_object fileContentObject)
        {
            IEnumerable<string> fileNames = null;
            IEnumerable<string> paths = null;

            var fileEntities = FileContentOvalHelper.GetFileContentEntitiesFromObjectType(fileContentObject);            
            var pattern = ((EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.pattern)).Value;
            
            if (fileContentObject.IsFilePathDefined())
            {
                var filePath = this.GetDictionaryWithElement(textfilecontent54_ItemsChoices.filepath,fileEntities);
                var filePathOperationResult = this.PathOperatorEvaluator.ProcessOperationFilePath(filePath);
                fileNames = filePathOperationResult.FileNames;
                paths = filePathOperationResult.Paths;
            }
            else
            {
                paths = this.ProcessOperationsPaths(fileEntities);    
                fileNames = this.ProcessOperationsFileNames(fileEntities, paths);                                          
            }
            
            var itemTypes = this.ProcessOperationsPatterns(fileContentObject, fileNames);
            
            return this.ProcessOperationsInstance(itemTypes,fileContentObject);
        }
 private void CreateFileObjectsWithFilePath(textfilecontent54_object fileContentObject, IEnumerable<string> filePaths, IEnumerable<string> patterns, IEnumerable<string> instances, List<ObjectType> fileContentObjects)
 {
     foreach (string filepath in filePaths)
         foreach (string pattern in patterns)
             foreach (string instance in instances)
                 fileContentObjects.Add(this.CreateObjectTypeFrom(fileContentObject, filepath, null, null, pattern, instance));
 }
Пример #3
0
        public static Dictionary<string, EntitySimpleBaseType> GetFileContentEntitiesFromObjectType(textfilecontent54_object textFileContentObject)
        {
            string fileName = textfilecontent54_ItemsChoices.filename.ToString();
            string filePath = textfilecontent54_ItemsChoices.filepath.ToString();
            string path = textfilecontent54_ItemsChoices.path.ToString();
            string pattern = textfilecontent54_ItemsChoices.pattern.ToString();
            string instance = textfilecontent54_ItemsChoices.instance.ToString();

            object[] allEntities = textFileContentObject.Items.ToArray();
            string[] allEntityNames = textFileContentObject.Textfilecontent54ItemsElementName.Select(i => i.ToString()).ToArray<String>();

            Dictionary<String, EntitySimpleBaseType> fileContentEntities = new Dictionary<string, EntitySimpleBaseType>();
            if (textFileContentObject.IsFilePathDefined())
            {
                fileContentEntities.Add(filePath, OvalHelper.GetEntityObjectByName(filePath, allEntities, allEntityNames));
            }
            else
            {
                fileContentEntities.Add(fileName, OvalHelper.GetEntityObjectByName(fileName, allEntities, allEntityNames));
                fileContentEntities.Add(path, OvalHelper.GetEntityObjectByName(path, allEntities, allEntityNames));
            }

            fileContentEntities.Add(pattern, OvalHelper.GetEntityObjectByName(pattern, allEntities, allEntityNames));
            fileContentEntities.Add(instance, OvalHelper.GetEntityObjectIntTypeByName(instance, allEntities, allEntityNames));
            return fileContentEntities;

        }
Пример #4
0
 public IEnumerable<ObjectType> CreateObjectTypeByCombinationOfEntities(
     textfilecontent54_object fileContentObject,
     IEnumerable<string> filePaths,
     IEnumerable<string> fileName,
     IEnumerable<string> paths,
     IEnumerable<string> patterns,
     IEnumerable<string> instances)
 {
     var fileContentObjects = new List<ObjectType>();
     fileContentObjects.AddRange(this.CreateFileObjects(fileContentObject, filePaths, fileName, paths, patterns, instances));
     return fileContentObjects;
 }
Пример #5
0
        public IEnumerable<ObjectType> CreateFileObjects(
            textfilecontent54_object fileContentObject,
            IEnumerable<string> filePaths,
            IEnumerable<string> fileNames,
            IEnumerable<string> paths,
            IEnumerable<string> patterns,
            IEnumerable<string> instances)
        {
            var fileContentObjects = new List<ObjectType>();

            if (fileContentObject.IsFilePathDefined())
                this.CreateFileObjectsWithFilePath(fileContentObject, filePaths, patterns, instances, fileContentObjects);
            else
                this.CreateFileObjectsWithoutFilePath(fileContentObject, fileNames, paths, patterns, instances, fileContentObjects);

            return fileContentObjects;
        }
Пример #6
0
        public TextFileContentProberTest()
        {
            FakeItemsToReturnByItemTypeGenerator =
                new ItemType[] 
                { 
                    CreateFakeTextFileContentItem(null, FAKE_PATH, FAKE_FILENAME, FAKE_PATTERN, FAKE_INSTANCE)
                };

            FakeColletedItems = 
                new CollectedItem[] 
                { 
                    ProbeHelper.CreateFakeCollectedItem(FakeItemsToReturnByItemTypeGenerator.First())
                };

            var textFileContent54ObjectsSample = ProbeHelper.GetFakeOvalDefinitions("definitionsSimple").objects.OfType<textfilecontent54_object>();
            this.TextFileContent54ObjectsWithoutBehaviors = textFileContent54ObjectsSample.First();
            this.TextFileContent54ObjectWithMultilineBehavior = textFileContent54ObjectsSample.Single(obj => obj.id.Equals("oval:modulo:obj:910"));
            this.TextFileContent54ObjectWithoutMultilineBehavior = textFileContent54ObjectsSample.Single(obj => obj.id.Equals("oval:modulo:obj:920"));
        }
        private IList<ItemType> ProcessOperationsPatterns(
            textfilecontent54_object fileContentObject, IEnumerable<string> completePaths)
        {
            var result = new List<ItemType>();
            var pattern = ((EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.pattern)).Value;
            var instance = ((EntitySimpleBaseType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.instance)).Value;
            var multilineBehavior = fileContentObject.IsMultiline();
            var singlelineBehavior = fileContentObject.IsSingleline();

            foreach (var filepath in completePaths)
            {
                var parameters =
                    TextFileContentObjectCollector.GetDictionaryWithParametersToSearchTextFileConten(
                        filepath, pattern, Int32.Parse(instance), multilineBehavior, singlelineBehavior);

                result.Add(this.CollectItem(parameters));

                parameters.Clear();
            }

            return result;
        }
        private IEnumerable<ItemType> ProcessOperationsInstance(IEnumerable<ItemType> itemTypes, textfilecontent54_object textFileContent)
        {
            var result = new List<ItemType>();

            var instanceEntity =
                (EntityObjectIntType)textFileContent.GetItemValue(textfilecontent54_ItemsChoices.instance);

            var comparator = new OvalComparatorFactory().GetComparator(instanceEntity.datatype);

            foreach (var itemType in itemTypes)
            {
                if (itemType.status == StatusEnumeration.exists)
                {
                    var textFileContentItem = (textfilecontent_item)itemType;
                    if (comparator.Compare(textFileContentItem.instance.Value, instanceEntity.Value, instanceEntity.operation))
                        result.Add(itemType);
                }
                else
                {
                    result.Add(itemType);
                }
            }

            return result;
        }
 private IEnumerable<string> ProcessVariableForPattern(textfilecontent54_object fileContentObject)
 {
     var fileName = (EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.pattern);
     return this.processVariablesForEntity(fileName);
 }
 private IEnumerable<string> ProcessVariableForInstance(textfilecontent54_object fileContentObject)
 {
     var instance = (EntityObjectIntType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.instance);
     return this.processVariablesForEntity(instance);
 }
 private void AssertTextFileContentObjectEntity(
     textfilecontent54_object textFileContentObject,
     textfilecontent54_ItemsChoices entityName,
     string expectedEntityValue)
 {
     var entityToAssert = (EntitySimpleBaseType)textFileContentObject.GetItemValue(entityName);
     Assert.IsNotNull(entityToAssert, "The entity cannot be null");
     Assert.AreEqual(expectedEntityValue, entityToAssert.Value, "An unexpected entity value was found.");
 }
        private void AssertEntityNamesOrder(textfilecontent54_object textFileContentObject)
        {
            if (textFileContentObject.IsFilePathDefined())
            {
                var firstElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(0);
                var secondElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(1);
                var thirdElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(2);
                var fourthElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(3);

                Assert.AreEqual(textfilecontent54_ItemsChoices.behaviors, firstElement, UNEXPECTED_ENTITY_ORDER);
                Assert.AreEqual(textfilecontent54_ItemsChoices.filepath, secondElement, UNEXPECTED_ENTITY_ORDER);
                Assert.AreEqual(textfilecontent54_ItemsChoices.pattern, thirdElement, UNEXPECTED_ENTITY_ORDER);
                Assert.AreEqual(textfilecontent54_ItemsChoices.instance, fourthElement, UNEXPECTED_ENTITY_ORDER);
            }
            else
            {
                var firstElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(0);
                var secondElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(1);
                var thirdElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(2);
                var fourthElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(3);
                var fifthElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(4);

                Assert.AreEqual(textfilecontent54_ItemsChoices.behaviors, firstElement, UNEXPECTED_ENTITY_ORDER);
                Assert.AreEqual(textfilecontent54_ItemsChoices.path, secondElement, UNEXPECTED_ENTITY_ORDER);
                Assert.AreEqual(textfilecontent54_ItemsChoices.filename, thirdElement, UNEXPECTED_ENTITY_ORDER);
                Assert.AreEqual(textfilecontent54_ItemsChoices.pattern, fourthElement, UNEXPECTED_ENTITY_ORDER);
                Assert.AreEqual(textfilecontent54_ItemsChoices.instance, fifthElement, UNEXPECTED_ENTITY_ORDER);
            }
        }
 public IEnumerable<String> EvaluateVariableForEntity(textfilecontent54_object fileContentObj, textfilecontent54_ItemsChoices entityName)
 {
     var fileObjectEntity = (EntitySimpleBaseType)fileContentObj.GetItemValue(entityName);
     var evaluatedEntity = this.FilePathVarEvaluator.EvaluateEntityVariable(fileObjectEntity);
     return evaluatedEntity == null ? null : evaluatedEntity.Distinct().ToArray();
 }
Пример #14
0
        private textfilecontent54_object CreateTextFileContentObject(
            EntityObjectStringType filePath,
            EntityObjectStringType fileName,
            EntityObjectStringType path,
            EntityObjectStringType pattern,
            EntityObjectIntType instance,
            Object[] behaviors)
        {
            var fileContentObject = new textfilecontent54_object();
            object[] items;
            textfilecontent54_ItemsChoices[] itemChoices;
            var hasBehaviors = (behaviors != null) && (behaviors.Count() > 0);
            var behaviorCount = behaviors.Count();

            if (filePath == null)
            {
                if (hasBehaviors)
                {
                    var entityCount = behaviorCount + 4;
                    items = new object[entityCount];
                    itemChoices = new textfilecontent54_ItemsChoices[entityCount];

                    for (int i = 0; i < behaviorCount; i++)
                    {
                        itemChoices[i] = textfilecontent54_ItemsChoices.behaviors;
                        items[i] = behaviors.ElementAt(i);
                    }

                    itemChoices[behaviorCount] = textfilecontent54_ItemsChoices.path;
                    itemChoices[behaviorCount + 1] = textfilecontent54_ItemsChoices.filename;
                    itemChoices[behaviorCount + 2] = textfilecontent54_ItemsChoices.pattern;
                    itemChoices[behaviorCount + 3] = textfilecontent54_ItemsChoices.instance;

                    items[behaviorCount] = path;
                    items[behaviorCount + 1] = fileName;
                    items[behaviorCount + 2] = pattern;
                    items[behaviorCount + 3] = instance;
                }
                else
                {
                    items = new EntitySimpleBaseType[4];
                    itemChoices = new textfilecontent54_ItemsChoices[4];
                    itemChoices[0] = textfilecontent54_ItemsChoices.path;
                    itemChoices[1] = textfilecontent54_ItemsChoices.filename;
                    itemChoices[2] = textfilecontent54_ItemsChoices.pattern;
                    itemChoices[3] = textfilecontent54_ItemsChoices.instance;
                    items[0] = path;
                    items[1] = fileName;
                    items[2] = pattern;
                    items[3] = instance;
                }
            }
            else
            {
                if (hasBehaviors)
                {
                    var entityCount = behaviorCount + 3;
                    items = new object[entityCount];
                    itemChoices = new textfilecontent54_ItemsChoices[entityCount];

                    for (int i = 0; i < behaviorCount; i++)
                    {
                        itemChoices[i] = textfilecontent54_ItemsChoices.behaviors;
                        items[i] = behaviors.ElementAt(i);
                    }

                    itemChoices[behaviorCount] = textfilecontent54_ItemsChoices.filepath;
                    itemChoices[behaviorCount + 1] = textfilecontent54_ItemsChoices.pattern;
                    itemChoices[behaviorCount + 2] = textfilecontent54_ItemsChoices.instance;

                    items[behaviorCount] = filePath;
                    items[behaviorCount + 1] = pattern;
                    items[behaviorCount + 2] = instance;
                }
                else
                {
                    items = new EntitySimpleBaseType[3];
                    itemChoices = new textfilecontent54_ItemsChoices[3];
                    itemChoices[0] = textfilecontent54_ItemsChoices.filepath;
                    itemChoices[1] = textfilecontent54_ItemsChoices.pattern;
                    itemChoices[2] = textfilecontent54_ItemsChoices.instance;
                    items[0] = filePath;
                    items[1] = pattern;
                    items[2] = instance;
                }

            }

            fileContentObject.Items = items;
            fileContentObject.Textfilecontent54ItemsElementName = itemChoices;

            return fileContentObject;
        }
Пример #15
0
        private ObjectType CreateObjectTypeFrom(textfilecontent54_object fileContentObject, string filePath, string fileName, string path, string pattern, string instance)
        {
            EntityObjectStringType filePathFrom = null;
            EntityObjectStringType pathFrom = null;
            EntityObjectStringType fileNameFrom = null;
            EntityObjectStringType newFilePath = null;
            EntityObjectStringType newPath = null;
            EntityObjectStringType newFileName = null;

            var patternFrom = (EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.pattern);
            var instanceFrom = (EntityObjectIntType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.instance);

            var newPattern = this.CopyEntityObjectStringType(patternFrom);
            newPattern.Value = !string.IsNullOrEmpty(pattern) ? pattern : newPattern.Value;

            var newInstance = this.CopyEntityObjectIntType(instanceFrom);
            newInstance.Value = !string.IsNullOrEmpty(instance) ? instance : newInstance.Value;

            var behaviors = fileContentObject.Items.OfType<Textfilecontent54Behaviors>().ToArray();
            if (fileContentObject.IsFilePathDefined())
            {
                filePathFrom = (EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.filepath);
                newFilePath = this.CopyEntityObjectStringType(filePathFrom);
                newFilePath.Value = !string.IsNullOrEmpty(filePath) ? filePath : newFilePath.Value;

                return this.CreateTextFileContentObject(newFilePath, null, null, newPattern, newInstance, behaviors);
            }
            else
            {
                pathFrom = (EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.path);
                fileNameFrom = (EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.filename);

                newPath = this.CopyEntityObjectStringType(pathFrom);
                newPath.Value = !string.IsNullOrEmpty(path) ? path : newPath.Value;

                newFileName = this.CopyEntityObjectStringType(fileNameFrom);
                newFileName.Value = !string.IsNullOrEmpty(fileName) ? fileName : newFileName.Value;

                return this.CreateTextFileContentObject(null, newFileName, newPath, newPattern, newInstance, behaviors);
            }
        }