From c628bb67928c54ad38d90fce24598cfbfe4ee002 Mon Sep 17 00:00:00 2001 From: ShadowFoxNixill Date: Mon, 13 Jan 2020 11:38:59 -0500 Subject: [PATCH] Fix #4 --- CS-NixLib-Test/src/GridTests.cs | 11 +++++++++++ CS-NixLib/src/Grid/CSVParser.cs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CS-NixLib-Test/src/GridTests.cs b/CS-NixLib-Test/src/GridTests.cs index 287254c..ee81576 100644 --- a/CS-NixLib-Test/src/GridTests.cs +++ b/CS-NixLib-Test/src/GridTests.cs @@ -1,3 +1,4 @@ +using System.IO; using System; using NUnit.Framework; using Nixill.Collections.Grid; @@ -55,6 +56,16 @@ public void GridManipTest() { toCSVAgain = CSVParser.GridToString(toGrid); Assert.AreEqual(toCSV, toCSVAgain); + + // Now test files + string tmp = Path.GetTempPath(); + string file = tmp + "test.csv"; + + CSVParser.GridToFile(testingGrid, file); + toGrid = CSVParser.FileToGrid(file); + toCSVAgain = CSVParser.GridToString(toGrid); + + Assert.AreEqual(toCSV, toCSVAgain); } } } \ No newline at end of file diff --git a/CS-NixLib/src/Grid/CSVParser.cs b/CS-NixLib/src/Grid/CSVParser.cs index 4d16bb4..c03976b 100644 --- a/CS-NixLib/src/Grid/CSVParser.cs +++ b/CS-NixLib/src/Grid/CSVParser.cs @@ -177,7 +177,7 @@ public static string GridToString(IGrid input) { public static void GridToFile(IGrid input, string file) { using (StreamWriter writer = new StreamWriter(file)) { foreach (string line in GridToStringEnumerable(input)) { - writer.WriteLine(input); + writer.WriteLine(line); } } }