public void ListFiles() { var io = new LocalFileIO("foo", "bar"); var files = io.ListFiles(".").Result; Assert.IsTrue(files.Length > 0); Assert.IsTrue(File.Exists(files[0])); }
static async Task <MessageResponse> ListFilesMessage(Message message, object userContext) { //For test purpose only //message.Properties.Add("sourcePath", @"C:/Users"); //********************* logReceivedMessage(message); #region Checking required properties if (!validateStringParams(message, "sourcePath")) { return(MessageResponse.Abandoned); } #endregion // Process code here try { string[] content = await localFileIO.ListFiles(message.Properties["sourcePath"], null); var moduleClient = userContext as ModuleClient; if (moduleClient == null) { throw new InvalidOperationException("UserContext doesn't exist. Not able to write in output."); } else { await moduleClient.SendEventAsync("ListFilesOutput", new Message(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(content)))); } } catch (Exception ex) { Console.WriteLine($"Error getting local file: {ex.Message}"); } Console.WriteLine("Done!"); return(MessageResponse.Completed); }