public void WriteAndDeleteFile_FileGone() { var io = new LocalFileIO("foo", "bar"); io.WriteFile(".", "test2.txt", GenerateTestBytes(), false).Wait(); io.RemoveFile(".", "test2.txt").Wait(); Assert.IsFalse(File.Exists(".\\test2.txt")); }
public void WriteAndReadFile_RoundtripData() { var io = new LocalFileIO("foo", "bar"); io.WriteFile(".", "test1.txt", GenerateTestBytes(), false).Wait(); var outFileBytes = io.GetFile(".", "test1.txt").Result; Assert.AreEqual("hello tests!", Encoding.UTF8.GetString(outFileBytes)); }
static async Task <MessageResponse> WriteFileMessage(Message message, object userContext) { //For test purpose only //message.Properties.Add("sourcePath", @"C:/Users"); //message.Properties.Add("sourceFilename", @"Test.txt"); //message.Properties.Add("append", @"False"); //********************* logReceivedMessage(message); #region Checking required properties if (!validateStringParams(message, "sourcePath", "sourceFilename")) { return(MessageResponse.Abandoned); } if (!validateStringParams(message, "append")) { message.Properties.Add("append", @"False"); Console.WriteLine("'append' property missed. 'append' set to 'False'."); } else { bool append = false; if (!bool.TryParse(message.Properties["append"], out append)) { Console.WriteLine($"Failed to convert 'append' value to boolean. Value is {message.Properties["append"]}"); return(MessageResponse.Abandoned); } } #endregion // Process code here try { await localFileIO.WriteFile(message.Properties["sourcePath"], message.Properties["sourceFilename"], message.GetBytes(), bool.Parse(message.Properties["append"])); } catch (Exception ex) { Console.WriteLine($"Error writing local file: {ex.Message}"); } Console.WriteLine("Done!"); return(MessageResponse.Completed); }