public void File_AbsolutePath_WithoutSession_ReturnsHintPath() { Assert.IsNull(ExecutionEvents.ActiveSession); var relativepath = @"excel\ascending.xlsx"; var hintpath = Path.Combine(TestDirectory, @"do not exist\no file.txt"); Assert.AreEqual(hintpath, File.AbsolutePath(relativepath, hintpath)); }
public void File_AbsolutePath_WithFullPathInput_ReturnsInput() { Assert.IsNull(ExecutionEvents.ActiveSession); string wspath = Path.Combine(TestDirectory, @"core\files\dummy.dyn"); var relativepath = @"excel\ascending.xlsx"; var hintpath = Path.Combine(TestDirectory, "core", relativepath); Assert.AreEqual(wspath, File.AbsolutePath(wspath, hintpath)); }
public void File_AbsolutePath_RelativePathDontExist() { Assert.IsNull(ExecutionEvents.ActiveSession); string wspath = Path.Combine(TestDirectory, @"core\files\dummy.dyn"); var session = new Mock <IExecutionSession>(); session.Setup(s => s.CurrentWorkspacePath).Returns(wspath); SetActiveSession(session.Object); var relativepath = @"do not exist\no file.txt"; var expectedpath = Path.Combine(TestDirectory, @"core\files", relativepath); Assert.AreEqual(expectedpath, File.AbsolutePath(relativepath)); SetActiveSession(null); }
public void File_AbsolutePath_WithValidHintPath_ReturnsHintPath() { Assert.IsNull(ExecutionEvents.ActiveSession); string wspath = Path.Combine(TestDirectory, @"core\files\dummy.dyn"); var session = new Mock <IExecutionSession>(); session.Setup(s => s.CurrentWorkspacePath).Returns(wspath); SetActiveSession(session.Object); var relativepath = @"excel\ascending.xlsx"; var hintpath = Path.Combine(TestDirectory, "core", relativepath); Assert.AreEqual(hintpath, File.AbsolutePath(relativepath, hintpath)); SetActiveSession(null); }
/// <summary> /// Write a list of lists into a file using a comma-separated values /// format. Outer list represents rows, inner lists represent columns. /// </summary> /// <param name="filePath">Path to write to</param> /// <param name="data">List of lists to write into CSV</param> /// <returns name="str">Contents of the text file.</returns> /// <search>write,text,file</search> public static void WriteToFile(string filePath, object[][] data) { using (var writer = new StreamWriter(File.AbsolutePath(filePath))) { foreach (var line in data) { int count = 0; foreach (var entry in line) { writer.Write(entry); if (++count < line.Length) { writer.Write(","); } } writer.WriteLine(); } } }
/// <summary> /// Write the image to a path, given the specified file name. /// </summary> /// <param name="path"></param> /// <param name="image">The image to write</param> /// <returns name="ok">It is successful or not.</returns> /// <search>write image,image,file,filepath</search> public static void WriteToFile(string path, Bitmap image) { image.Save(File.AbsolutePath(path)); }