private file_object CreateFileObject(EntityObjectStringType filePath, EntityObjectStringType path, EntityObjectStringType fileName) { file_object fileObject = new file_object(); EntityObjectStringType[] items; file_object_ItemsChoices[] itemChoices; if (filePath != null) { items = new EntityObjectStringType[1]; itemChoices = new file_object_ItemsChoices[1]; items[0] = filePath; itemChoices[0] = file_object_ItemsChoices.filepath; } else { items = new EntityObjectStringType[2]; itemChoices = new file_object_ItemsChoices[2]; items[0] = path; items[1] = fileName; itemChoices[0] = file_object_ItemsChoices.path; itemChoices[1] = file_object_ItemsChoices.filename; } fileObject.Items = items; fileObject.FileObjectItemsElementName = itemChoices; return fileObject; }
public IEnumerable<ObjectType> CreateObjectTypeByCombinationOfEntities(file_object fileObject, IEnumerable<string> filePaths, IEnumerable<string> paths, IEnumerable<string> fileNames) { var fileObjects = new List<ObjectType>(); if (fileObject.IsFilePathSet()) fileObjects.AddRange(CreateFileObjectWithFilePath(fileObject, filePaths)); else fileObjects.AddRange(this.CreateFileObjectWithoutFilePath(fileObject, paths, fileNames)); return fileObjects; }
private string getFileNameEntityValueFromFileObject(file_object fileObject) { var allFileEntities = OvalHelper.GetFileEntitiesFromObjectType(fileObject); return allFileEntities[file_object_ItemsChoices.filename.ToString()].Value; }
private FileItemTypeGenerator GetMockedFileItemTypeGenerator(string fileObjectID, string[] fakeFoundPaths, out file_object fileObject) { oval_definitions definitions = ProbeHelper.GetFakeOvalDefinitions(DEFINITIONS_REGEX_ON_VALUE); fileObject = (file_object)ProbeHelper.GetOvalComponentByOvalID(definitions, fileObjectID); List<WmiObject> fakeWmiObjects = new List<WmiObject>(); foreach(var fakePath in fakeFoundPaths) fakeWmiObjects.Add(this.createFakeWmiObject(fakePath, "Application", 100)); MockRepository mocks = new MockRepository(); WmiDataProvider fakeWmiProvider = mocks.DynamicMock<WmiDataProvider>(); Expect.Call(fakeWmiProvider.SearchWmiObjects(null, null)).IgnoreArguments().Return(fakeWmiObjects.ToArray()); mocks.ReplayAll(); return new FileItemTypeGenerator() { SystemDataSource = new FileObjectCollector() { WmiDataProvider = fakeWmiProvider } }; }