public void ProcessDirectory_of_InValid_Path_without_Subdirectories_Does_Not_Add_Path() { string targetDirectory = @"C:\Foo\Bar"; IValidateFile validator = Substitute.For <IValidateFile>(); validator.IsValidFile(targetDirectory).Returns(true); IProcessFile processor = new FileList(validator); FileList processorResult = (FileList)RecursiveFileProcessor.ProcessDirectory(targetDirectory, processor, includeSubDirectories: false); Assert.IsTrue(processorResult.Paths.Count == 0); }
public void ProcessDirectory_of_Valid_Path_without_Subdirectories_Adds_Path() { string validFilePath = Process.GetCurrentProcess().MainModule.FileName; string targetDirectory = Path.GetDirectoryName(validFilePath); IValidateFile validator = Substitute.For <IValidateFile>(); validator.IsValidFile(validFilePath).Returns(true); IProcessFile processor = new FileList(validator); FileList processorResult = (FileList)RecursiveFileProcessor.ProcessDirectory(targetDirectory, processor, includeSubDirectories: false); Assert.IsTrue(processorResult.Paths.Count == 1); Assert.AreEqual(processorResult.Paths[0], validFilePath); }
public void ProcessDirectory_of_InValid_Path_without_Subdirectories_Events_Messenger() { string targetDirectory = @"C:\Foo\Bar"; IValidateFile validator = Substitute.For <IValidateFile>(); validator.IsValidFile(targetDirectory).Returns(true); IProcessFile processor = new FileList(validator); var wasCalled = false; RecursiveFileProcessor.Messenger += (e) => wasCalled = true; RecursiveFileProcessor.ProcessDirectory(targetDirectory, processor, includeSubDirectories: false); Assert.IsTrue(wasCalled); }
static void Main(string[] args) { /* * // The Edge runtime gives us the connection string we need -- it is injected as an environment variable * string connectionString = Environment.GetEnvironmentVariable("EdgeHubConnectionString"); * * // Cert verification is not yet fully functional when using Windows OS for the container * bool bypassCertVerification = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); * if (!bypassCertVerification) InstallCert(); * Init(connectionString, bypassCertVerification).Wait(); * * // Wait until the app unloads or is cancelled * var cts = new CancellationTokenSource(); * AssemblyLoadContext.Default.Unloading += (ctx) => cts.Cancel(); * Console.CancelKeyPress += (sender, cpe) => cts.Cancel(); * WhenCancelled(cts.Token).Wait(); */ // Local testing RecursiveFileProcessor.ProcessDirectory("data"); }