1
mirror of https://github.com/carlospolop/PEASS-ng synced 2025-03-28 18:33:05 +01:00

Delete SearchHelperTests.cs

This commit is contained in:
Carlos Polop 2023-05-08 17:20:30 +02:00 committed by GitHub
parent 711d9f1a95
commit 7bb66d2182
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,57 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using winPEAS.Helpers;
using winPEAS.Helpers.Search;
using Path = Alphaleonis.Win32.Filesystem.Path;
namespace winPEAS.Tests
{
[TestClass]
public class SearchHelperTests
{
[TestMethod]
public void TestGetFilesFastBypassesMAX_PATHLimit()
{
// Create a folder with files that have names longer than 260 characters
string folder = "C:\\Temp\\TestFolder";
var createdirectory = new DirectoryInfo(folder);
createdirectory.Create();
for (int i = 0; i < 10; i++)
{
string longName = new string('a', 300);
string fileName = Path.Combine(folder, $"{longName}_{i}.txt");
// Use the fsutil command to create a file with a long name
ProcessStartInfo startInfo = new ProcessStartInfo("fsutil", $"file createnew {fileName} 0")
{
UseShellExecute = true,
CreateNoWindow = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
ErrorDialog = true,
WindowStyle = ProcessWindowStyle.Normal
};
Process.Start(startInfo);
}
// Call the GetFilesFast method to get a list of all the files in the folder
List<CustomFileInfo> files = SearchHelper.GetFilesFast(folder);
// Get a list of all the files in the folder using System.IO.Directory.GetFiles
string[] directoryFiles = System.IO.Directory.GetFiles(folder);
List<FileInfo> expectedFiles = directoryFiles.Select(f => new FileInfo(f)).ToList();
// Make sure the lists have the same number of elements
Assert.AreEqual(expectedFiles.Count, files.Count);
}
}
}