public void testCSVUtilEscapeUnescape() { var util = new ImportExportNGUILocalization.NGUICSVUtil(); string simpleTest = "this is simple"; string result = util.escapeCSVString(simpleTest); Assert.AreEqual(simpleTest, result); Assert.AreEqual(simpleTest, util.unescapeCSVString(result)); string hasACommaInIt = "I have a comma, in me"; result = util.escapeCSVString(hasACommaInIt); //oxford won't save you now! Assert.AreEqual(result, "\"I have a comma, in me\""); Assert.AreEqual(hasACommaInIt, util.unescapeCSVString(result)); string commaAndAQuote = "I have a comma, a \"quote\", and something else"; result = util.escapeCSVString(commaAndAQuote); string mockResult = "\"I have a comma, a \"\"quote\"\", and something else\""; Assert.AreEqual(result, mockResult); Assert.AreEqual(commaAndAQuote, util.unescapeCSVString(mockResult)); }
public void testCSVUtilEscapeUnescape() { var util = new ImportExportNGUILocalization.NGUICSVUtil(); string simpleTest = "this is simple"; string result = util.escapeCSVString(simpleTest); Assert.AreEqual(simpleTest, result); Assert.AreEqual(simpleTest, util.unescapeCSVString(result)); string hasACommaInIt = "I have a comma, in me"; result = util.escapeCSVString(hasACommaInIt); //oxford won't save you now! Assert.AreEqual(result, "\"I have a comma, in me\""); Assert.AreEqual(hasACommaInIt, util.unescapeCSVString(result)); string commaAndAQuote = "I have a comma, a \"quote\", and something else"; result = util.escapeCSVString(commaAndAQuote); string mockResult = "\"I have a comma, a \"\"quote\"\", and something else\""; Assert.AreEqual(result, mockResult); Assert.AreEqual(commaAndAQuote, util.unescapeCSVString(mockResult)); }