public IEnumerable<ObjectType> ProcessVariables(ObjectType objcetType)
        {
            var textFileContentObject = (textfilecontent54_object)objcetType;
            var textFileContentObjects = new List<ObjectType>();
            IEnumerable<string> variablesFromFilePath = null;
            IEnumerable<string> variablesFromFileName = null;
            IEnumerable<string> variablesFrompath = null;
            if (textFileContentObject.IsFilePathDefined())
                variablesFromFilePath = this.ProcessVariableForFilePath(textFileContentObject);
            else
            {
                variablesFromFileName = this.ProcessVariableForFileName(textFileContentObject);
                variablesFrompath = this.ProcessVariableForPath(textFileContentObject);
            }

            var variablesFrompattern = this.ProcessVariableForPattern(textFileContentObject);
            var variablesFromInstance = this.ProcessVariableForInstance(textFileContentObject);

            if (this.IsVariablesWasProcessed(variablesFromFilePath, variablesFromFileName, variablesFrompattern, variablesFrompath, variablesFromInstance))
            {
                var factory = new TextFileContentObjectFactory();
                textFileContentObjects.AddRange(factory.CreateObjectTypeByCombinationOfEntities(textFileContentObject,
                        variablesFromFilePath,
                        variablesFromFileName,
                        variablesFrompath,
                        variablesFrompattern,
                        variablesFromInstance));
            }

            return textFileContentObjects;
        }
        public void Should_be_possible_to_create_itemType_defined_with_path_and_filename_entities()
        {
            var objectType = ProbeHelper.GetDefinitionObjectTypeByID("definitionsSimple", "910");
            var paths = new string[] { @"c:\windows" };
            var filenames = new string[] { @"win.ini" };
            var patterns = new string[] { "3g2=MPEG" };
            var instances = new string[] { "3g2=MPEGVideo", "3gp2=MPEGVideo" };

            var createdFileObjects =
                new TextFileContentObjectFactory()
                    .CreateFileObjects((textfilecontent54_object)objectType, null, filenames, paths, patterns, instances);

            Assert.IsNotNull(createdFileObjects, "The file objects were not created.");
            Assert.AreEqual(2, createdFileObjects.Count());

            var firstObject = (textfilecontent54_object)createdFileObjects.First();
            var secondObject = (textfilecontent54_object)createdFileObjects.ElementAt(1);

            Assert.IsNull(firstObject.GetItemValue(textfilecontent54_ItemsChoices.filepath));
            AssertEntityNamesOrder(firstObject);
            AssertTextFileContentObjectEntity(firstObject, textfilecontent54_ItemsChoices.path, paths.Single());
            AssertTextFileContentObjectEntity(firstObject, textfilecontent54_ItemsChoices.filename, filenames.Single());
            AssertTextFileContentObjectEntity(firstObject, textfilecontent54_ItemsChoices.pattern, patterns.Single());
            AssertTextFileContentObjectEntity(firstObject, textfilecontent54_ItemsChoices.instance, instances.First());

            Assert.IsNull(secondObject.GetItemValue(textfilecontent54_ItemsChoices.filepath));
            AssertEntityNamesOrder(secondObject);
            AssertTextFileContentObjectEntity(secondObject, textfilecontent54_ItemsChoices.path, paths.Single());
            AssertTextFileContentObjectEntity(secondObject, textfilecontent54_ItemsChoices.filename, filenames.Single());
            AssertTextFileContentObjectEntity(secondObject, textfilecontent54_ItemsChoices.pattern, patterns.Single());
            AssertTextFileContentObjectEntity(secondObject, textfilecontent54_ItemsChoices.instance, instances.ElementAt(1));
        }
Exemplo n.º 3
0
        public IEnumerable <ObjectType> ProcessVariables(ObjectType objcetType)
        {
            var textFileContentObject  = (textfilecontent54_object)objcetType;
            var textFileContentObjects = new List <ObjectType>();
            IEnumerable <string> variablesFromFilePath = null;
            IEnumerable <string> variablesFromFileName = null;
            IEnumerable <string> variablesFrompath     = null;

            if (textFileContentObject.IsFilePathDefined())
            {
                variablesFromFilePath = this.ProcessVariableForFilePath(textFileContentObject);
            }
            else
            {
                variablesFromFileName = this.ProcessVariableForFileName(textFileContentObject);
                variablesFrompath     = this.ProcessVariableForPath(textFileContentObject);
            }

            var variablesFrompattern  = this.ProcessVariableForPattern(textFileContentObject);
            var variablesFromInstance = this.ProcessVariableForInstance(textFileContentObject);

            if (this.IsVariablesWasProcessed(variablesFromFilePath, variablesFromFileName, variablesFrompattern, variablesFrompath, variablesFromInstance))
            {
                var factory = new TextFileContentObjectFactory();
                textFileContentObjects.AddRange(factory.CreateObjectTypeByCombinationOfEntities(textFileContentObject,
                                                                                                variablesFromFilePath,
                                                                                                variablesFromFileName,
                                                                                                variablesFrompath,
                                                                                                variablesFrompattern,
                                                                                                variablesFromInstance));
            }

            return(textFileContentObjects);
        }
        public void Should_be_possible_to_create_itemtype_defined_with_filepath_entity()
        {
            var objectType = ProbeHelper.GetDefinitionObjectTypeByID("definitionsSimple", "920");
            var filepaths = new string[] { @"c:\windows\win.ini" };
            var patterns = new string[] { "VERSION.*" };
            var instances = new string[] { "1" };

            var createdFileObjects =
                new TextFileContentObjectFactory()
                    .CreateFileObjects((textfilecontent54_object)objectType, filepaths, null, null, patterns, instances);

            Assert.IsNotNull(createdFileObjects, "The file objects were not created.");
            Assert.AreEqual(1, createdFileObjects.Count());

            var firstObject = (textfilecontent54_object)createdFileObjects.First();
            Assert.IsNull(firstObject.GetItemValue(textfilecontent54_ItemsChoices.path));
            Assert.IsNull(firstObject.GetItemValue(textfilecontent54_ItemsChoices.filename));

            AssertEntityNamesOrder(firstObject);
            AssertTextFileContentObjectEntity(firstObject, textfilecontent54_ItemsChoices.filepath, filepaths.Single());
            AssertTextFileContentObjectEntity(firstObject, textfilecontent54_ItemsChoices.pattern, patterns.Single());
            AssertTextFileContentObjectEntity(firstObject, textfilecontent54_ItemsChoices.instance, instances.First());
        }
        public void Should_be_possible_to_create_new_object_type_keeping_the_behavior_entity_from_source_object()
        {
            var objectType = ProbeHelper.GetDefinitionObjectTypeByID("definitionsSimple", "920");
            var filepaths = new string[] { @"c:\windows\win.ini" };
            var patterns = new string[] { "VERSION.*" };
            var instances = new string[] { "1" };

            var createdFileObjects = 
                new TextFileContentObjectFactory()
                    .CreateFileObjects((textfilecontent54_object)objectType, filepaths, null, null, patterns, instances);

            Assert.IsNotNull(createdFileObjects, "The file objects were not created.");
            Assert.AreEqual(1, createdFileObjects.Count());
            var textFileObject = (textfilecontent54_object)createdFileObjects.Single();
            var multiLineBehavior = (Textfilecontent54Behaviors)((textfilecontent54_object)textFileObject).Items.OfType<Textfilecontent54Behaviors>().Single();
            Assert.IsFalse(multiLineBehavior.multiline);
            Assert.IsFalse(textFileObject.IsMultiline(), "Unexpected behavior value was found.");
            
        }