I have the following test which seems to produce same strings but Assert.AreEqual fails.
[TestMethod]
public void Decompressed_test_should_equal_to_text_before_compression()
{
TextCompressor compressor = new TextCompressor();
Random r = new Random((int)DateTime.Now.Ticks);
for (int i = 500; i < 1500; i++)
{
char[] testArray = new char[i];
for (int j = 0; j < i; j++)
{
char randomChar = (char)(r.Next(256, 65536));
testArray[j] = randomChar;
}
string testString = new String(testArray);
string compressed = compressor.Compress(testString);
string decompressed = compressor.Decompress(compressed);
Assert.AreEqual(testString.Length, decompressed.Length);
Assert.AreEqual(testString, decompressed, false, CultureInfo.InvariantCulture);
}
}
compressor.Compress and compressor.Decompress does some compression and decompression with GZipStream.
It passes if I try (65, 90) instead of (256, 65536) so I am guessing it has something to do with unicode. I tried CurrentCulture and no culture at all instead of InvariantCulture and it still fails. But the resulting strings appear to be the same:
Assert.AreEqual failed.
Expected:
<☔ฺ疉鎷얚�跨꿌沩얫嘹֨ز항們嵜浮䑹ﴰ靄斳薃픢萁⯬쫎ʛ�⫕蝺ꄗ穌넢뇌䶆멊큀퉆䐫̥괊⑆놸僥̅ᵀ㣚ꢅ뺓䇚녚伀讍홬䈕�캾撏Ჴ孢黮摠뮡䌦윃ᬳ狚䆙툾훶䏤ꛈṻ⟧㉖鮸蒵萗냤퇅서㪨瀲鰪残䓴ﯘ넃櫜㑦䢻쮓죣䕱䶘㴝姳뿝嘼ᷨ㗬꺬櫣涷꠶浒껅က㷕䩉毎覛�⧹䮯嬇힚艐Ὑ쇕횻鸙蹻硐���䈆쓖⸛錼鰙ኰ乒⺴썓힠䵓ꅄⵈ桃怅㾈枟⏠ﻪ폫ﺍ琖ퟰ乼�쩐鑈푷᫇蕱늛�쭡�䙠ⲓᒇꪮ툅⃑ꦴ돻♹ᢋ麝熪뚭Ћ䌚�娯钮⡃㪿ᅰ⤩㥍車䎘磛蚾ㅸ擫떦蝳分鰽䠺ꭍ튘폻⥽ⳉ历驿똮�⯴⋟Ḋ룴墭䐣앾郢�ᵸᮄ杗奪騑硼佑烑鄗䳘핬溴墽炁ࣘヲ栥풼ಃ斗狹就쵎嬒瀃碂밎崹䎐貇汫踖�뢸숥퍞르뗿䭯䖝䱅�䵱꽔븽䢴ꁅ⟼�蒠癸ꩽ靔临䚝﹗⩏鍁Ꮨ䷇쁐쨒ʊ쪦鄭借滋铆ᮉ嚃ᩨိ펇ꮼ뇄』ᰉ㕾枒鯅蛺䠿櫄築픆车똅렬㈆ﹼἋ荞괋랆偦뤰䝷핸⹝屑素蝨怀猔勛碉퀪睹�Ⓥ䍙ಗ䤮뾿谢ꁼ戻ﮖᆯ콧偪ﺯ븭碇쮢籍⁜왋壝駡暷샖ࣵ艫䃴厫ᢉ慨䁆ꂴ溘欋옭螶䦗跠﨔膉痹邘⋫吪멚埣ꯕ扌옘广犵肖街�㶕畅몡ↇ꠫襤픧ၥ帻놤ਰ惘똞颤糴쫼鿋䬝穫⺁峁踷锝副鰀嗊⹀谲遲�䩢푑팾��糔뭯ࣷ䷴䬾갭ⶵ᾿틩魨㵻恬҅པᣄⲪ豩뛌꛵㥨몙〼△⏮큤�亃ꢡ웼ఐ칇뻻펂㢓吋䂃䨠䕱>.
Actual:
<☔ฺ疉鎷얚�跨꿌沩얫嘹֨ز항們嵜浮䑹ﴰ靄斳薃픢萁⯬쫎ʛ�⫕蝺ꄗ穌넢뇌䶆멊큀퉆䐫̥괊⑆놸僥̅ᵀ㣚ꢅ뺓䇚녚伀讍홬䈕�캾撏Ჴ孢黮摠뮡䌦윃ᬳ狚䆙툾훶䏤ꛈṻ⟧㉖鮸蒵萗냤퇅서㪨瀲鰪残䓴ﯘ넃櫜㑦䢻쮓죣䕱䶘㴝姳뿝嘼ᷨ㗬꺬櫣涷꠶浒껅က㷕䩉毎覛�⧹䮯嬇힚艐Ὑ쇕횻鸙蹻硐���䈆쓖⸛錼鰙ኰ乒⺴썓힠䵓ꅄⵈ桃怅㾈枟⏠ﻪ폫ﺍ琖ퟰ乼�쩐鑈푷᫇蕱늛�쭡�䙠ⲓᒇꪮ툅⃑ꦴ돻♹ᢋ麝熪뚭Ћ䌚�娯钮⡃㪿ᅰ⤩㥍車䎘磛蚾ㅸ擫떦蝳分鰽䠺ꭍ튘폻⥽ⳉ历驿똮�⯴⋟Ḋ룴墭䐣앾郢�ᵸᮄ杗奪騑硼佑烑鄗䳘핬溴墽炁ࣘヲ栥풼ಃ斗狹就쵎嬒瀃碂밎崹䎐貇汫踖�뢸숥퍞르뗿䭯䖝䱅�䵱꽔븽䢴ꁅ⟼�蒠癸ꩽ靔临䚝﹗⩏鍁Ꮨ䷇쁐쨒ʊ쪦鄭借滋铆ᮉ嚃ᩨိ펇ꮼ뇄』ᰉ㕾枒鯅蛺䠿櫄築픆车똅렬㈆ﹼἋ荞괋랆偦뤰䝷핸⹝屑素蝨怀猔勛碉퀪睹�Ⓥ䍙ಗ䤮뾿谢ꁼ戻ﮖᆯ콧偪ﺯ븭碇쮢籍⁜왋壝駡暷샖ࣵ艫䃴厫ᢉ慨䁆ꂴ溘欋옭螶䦗跠﨔膉痹邘⋫吪멚埣ꯕ扌옘广犵肖街�㶕畅몡ↇ꠫襤픧ၥ帻놤ਰ惘똞颤糴쫼鿋䬝穫⺁峁踷锝副鰀嗊⹀谲遲�䩢푑팾��糔뭯ࣷ䷴䬾갭ⶵ᾿틩魨㵻恬҅པᣄⲪ豩뛌꛵㥨몙〼△⏮큤�亃ꢡ웼ఐ칇뻻펂㢓吋䂃䨠䕱>.
What am I missing?