protected override void InitializeCustomFileProvider() { var wmiProvider = WmiDataProviderFactory.CreateWmiDataProviderForFileSearching(TargetInfo); var fileProvider = new WindowsFileProvider(TargetInfo, wmiProvider); CustomFileProvider = fileProvider; }
public void Should_be_possible_to_get_AdministrativeSharePath_from_hostname_and_localFilepath() { var fileContentProvider = new WindowsFileProvider(ProbeHelper.CreateFakeTarget()); string administrativeSharePath = fileContentProvider.GetAdministrativeSharePathFromLocalFilepath("mss-rj-001", @"c:\temp\file1.txt"); Assert.IsFalse(string.IsNullOrEmpty(administrativeSharePath), "The result string cannot be null or empty."); Assert.AreEqual(administrativeSharePath, @"\\mss-rj-001\c$\temp\file1.txt", "Unexpected result was found."); }
public void Should_be_possible_to_get_files_from_given_directory_path_using_FileSystemDataSource() { // Arrange var fakeTarget = ProbeHelper.CreateFakeTarget(); var fakeWmiDataProvider = this.GetMockedWmiDataProvider(); var fileDataSource = new WindowsFileProvider(fakeTarget) { WmiDataProvider = fakeWmiDataProvider }; // Act var returnedFiles = fileDataSource.GetFileChildren("c:\\temp").ToList(); // Assert this.AssertReturnedFiles(returnedFiles); }
public async Task CreatesEventsFile() { var repository = new SqliteRepository(); var fileProvider = new WindowsFileProvider(); var eventStore = new EventSource(repository, fileProvider); using var fileWatcher = new WindowsFileSystemWatcher(fileProvider); using var file = new TemporaryFile(); file.Append("InitialText"); using var target = new SourceControl(fileProvider, eventStore, fileWatcher); await target.Add(file.Fullname); Assert.IsTrue(fileProvider.Exists($"{file.Fullname}.events")); Assert.IsFalse(fileProvider.IsEmpty($"{file.Fullname}.events")); }
public async Task PreventsDuplicateEvents() { var eventCount = 0; using (var file = new TemporaryFile()) { var fileProvider = new WindowsFileProvider(); var target = new WindowsFileSystemWatcher(fileProvider); target.Monitor(file.Fullname); target.Changed += (e) => { eventCount++; }; file.Append("test"); file.Append("test"); } await Task.Delay(1000); // Gives the OS enough time to dispatch the event Assert.AreEqual(1, eventCount); }
public void CreateWmiParametersTest() { var target = new WindowsFileProvider(null); var fileParameters = target.CreateWmiParameters("c:\\temp\\file.ext"); CheckWmiParametersCount(fileParameters, 4); AssertWmiFileFilter(fileParameters, WqlFileParameters.Drive, "c:"); AssertWmiFileFilter(fileParameters, WqlFileParameters.Path, @"\\temp\\"); AssertWmiFileFilter(fileParameters, WqlFileParameters.FileName, "file"); AssertWmiFileFilter(fileParameters, WqlFileParameters.Extension, "ext"); var folderParameters = target.CreateWmiParameters("c:\\temp\\sgct"); CheckWmiParametersCount(folderParameters, 3); Assert.IsFalse(folderParameters.ContainsKey(WqlFileParameters.Extension.ToString()), "For folder searching extension parameter should not exists"); AssertWmiFileFilter(folderParameters, WqlFileParameters.Drive, "c:"); AssertWmiFileFilter(folderParameters, WqlFileParameters.Path, @"\\temp\\"); AssertWmiFileFilter(folderParameters, WqlFileParameters.FileName, "sgct"); }
public async Task AppendsEvents() { var repository = new SqliteRepository(); var fileProvider = new WindowsFileProvider(); var eventStore = new EventSource(repository, fileProvider); using var fileWatcher = new WindowsFileSystemWatcher(fileProvider); using var file = new TemporaryFile(); file.Append("InitialText"); using var target = new SourceControl(fileProvider, eventStore, fileWatcher); await target.Add(file.Fullname); file.Append("AdditionalText"); await Task.Delay(10000); var lines = await repository.ReadRecordsAsync($"{file.Fullname}.events").CountAsync(); Assert.AreEqual(2, lines); }
protected override void ConfigureObjectCollector() { if (base.ObjectCollector == null) { var connectionScope = ((FileConnectionProvider)FileConnectionProvider).ConnectionScope; var newWmiDataProvider = new WmiDataProvider(connectionScope); var newFileProvider = new WindowsFileProvider(TargetInfo) { WmiDataProvider = newWmiDataProvider }; ObjectCollector = new TextFileContentObjectCollector() { FileContentProvider = newFileProvider, TargetInfo = TargetInfo }; FileDataSource = new FileObjectCollector() { WmiDataProvider = newWmiDataProvider }; } if (base.ItemTypeGenerator == null) { var newFileProvider = new WindowsFileProvider(this.TargetInfo) { WmiDataProvider = WmiDataProviderFactory .CreateWmiDataProviderForFileSearching(this.TargetInfo) }; var newOperationEvaluator = new TextFileContentEntityOperationEvaluator(ObjectCollector, newFileProvider, FamilyEnumeration.windows); ItemTypeGenerator = new TextFileContentItemTypeGenerator() { OperationEvaluator = newOperationEvaluator }; } }
public MetabaseObjectCollector(WindowsFileProvider fileProvider) { try { var metabaseFileLines = fileProvider.GetFileLinesContentFromHost(METABASE_FILENAME); if (metabaseFileLines != null) { this.MetabaseFileContent = String.Join(Environment.NewLine, metabaseFileLines); var mbSchemaFileLines = fileProvider.GetFileLinesContentFromHost(MB_SCHEMA_FILENAME); if (mbSchemaFileLines != null) { this.MetabaseSchemaContent = String.Join(Environment.NewLine, mbSchemaFileLines); } } } catch (Exception) { this.MetabaseFileContent = string.Empty; this.MetabaseSchemaContent = string.Empty; } }
public FileEffectiveRights53ItemTypeGenerator( WindowsFileProvider fileProvider, FileEffectiveRights53ObjectCollector objectCollector) { this.FileProvider = fileProvider; this.ObjectCollector = objectCollector; }