diff --git a/ClosedXML_Tests/Utils/StreamHelper.cs b/ClosedXML_Tests/Utils/StreamHelper.cs
index b68a11f..8ecb4f9 100644
--- a/ClosedXML_Tests/Utils/StreamHelper.cs
+++ b/ClosedXML_Tests/Utils/StreamHelper.cs
@@ -51,7 +51,7 @@
throw new ArgumentException("Can't write to stream", "pStream");
}
- #endregion
+ #endregion Check params
foreach (byte b in pBynaryArray)
{
@@ -86,7 +86,7 @@
throw new ArgumentException("Can't write to stream", "streamToWrite");
}
- #endregion
+ #endregion Check params
var buf = new byte[512];
long length;
@@ -135,37 +135,53 @@
throw new ArgumentException("Must be in position 0", "other");
}
- #endregion
+ #endregion Check
- var stringOne = new StreamReader(one).ReadToEnd().StripColumnWidths(stripColumnWidths);
- var stringOther = new StreamReader(other).ReadToEnd().StripColumnWidths(stripColumnWidths);
+ var stringOne = new StreamReader(one).ReadToEnd().RemoveIgnoredParts(stripColumnWidths, ignoreGuids: true);
+ var stringOther = new StreamReader(other).ReadToEnd().RemoveIgnoredParts(stripColumnWidths, ignoreGuids: true);
return stringOne == stringOther;
}
+ private static string RemoveIgnoredParts(this string s, Boolean ignoreColumnWidths, Boolean ignoreGuids)
+ {
+ if (ignoreColumnWidths)
+ s = RemoveColumnWidths(s);
+
+ if (ignoreGuids)
+ s = RemoveGuids(s);
+
+ return s;
+ }
+
private static Regex columnRegex = new Regex("", RegexOptions.Compiled);
private static Regex widthRegex = new Regex("width=\"\\d+(\\.\\d+)?\"\\s+", RegexOptions.Compiled);
- private static string StripColumnWidths(this string s, bool stripIt)
+ private static String RemoveColumnWidths(String s)
{
- if (!stripIt)
- return s;
- else
- {
- var replacements = new Dictionary();
-
- foreach (var m in columnRegex.Matches(s).OfType())
- {
- var original = m.Groups[0].Value;
- var replacement = widthRegex.Replace(original, "");
- replacements.Add(original, replacement);
- }
+ var replacements = new Dictionary();
- foreach (var r in replacements)
- {
- s = s.Replace(r.Key, r.Value);
- }
- return s;
+ foreach (var m in columnRegex.Matches(s).OfType())
+ {
+ var original = m.Groups[0].Value;
+ var replacement = widthRegex.Replace(original, "");
+ replacements.Add(original, replacement);
}
+
+ foreach (var r in replacements)
+ {
+ s = s.Replace(r.Key, r.Value);
+ }
+ return s;
+ }
+
+ private static Regex guidRegex = new Regex(@"{[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}}", RegexOptions.Compiled | RegexOptions.Multiline);
+
+ private static String RemoveGuids(String s)
+ {
+ return guidRegex.Replace(s, delegate (Match m)
+ {
+ return string.Empty;
+ });
}
}
-}
\ No newline at end of file
+}