public void ParseLuContent(string fileName) { // var luContent = "# Help"+ Environment.NewLine + "- help" + Environment.NewLine + "- I need help" + Environment.NewLine + "- please help"; var path = Path.Combine(Directory.GetCurrentDirectory(), "Fixtures", fileName + ".txt"); Console.WriteLine(path); var luContent = File.ReadAllText(path); luContent = luContent.Substring(0, luContent.Length); var result = LuParser.Parse(luContent); if (string.Equals(fileName, "LU_Sections") || string.Equals(fileName, "SectionsLU")) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { fileName += "_Windows"; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { fileName += "_Unix"; } } LuResource expected = JsonConvert.DeserializeObject <LuResource>(File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "Fixtures", fileName + ".json"))); var serializedResult = JsonConvert.SerializeObject(result).Replace("\\r", string.Empty); var serializedExpected = JsonConvert.SerializeObject(expected).Replace("\\r", string.Empty); Assert.Equal(serializedResult, serializedExpected); }
public void ParseLuContentAutomated(string fileName) { var path = Path.Combine(Directory.GetCurrentDirectory(), "Fixtures", fileName + ".txt"); var luContent = File.ReadAllText(path); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && luContent.Contains("\r")) { luContent = luContent.Replace("\r", string.Empty); } var result = LuParser.Parse(luContent); var serializedResult = JsonConvert.SerializeObject(result); LuResource expected = JsonConvert.DeserializeObject <LuResource>(File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "Fixtures", fileName + ".json")).Replace("\r", string.Empty)); var serializedExpected = JsonConvert.SerializeObject(expected); var serExpected = SanitizeString(serializedExpected); var serResult = SanitizeString(serializedResult); Assert.Equal(serExpected, serResult); }