From be91164499b263fc4c716c6d44c69f440f8ab634 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 22 Apr 2020 10:30:26 -0400 Subject: fix some stateful tests also fixes some warnings about culture-specific string comparisons --- IrcTokens/Tests/StatefulDecoderTests.cs | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'IrcTokens/Tests/StatefulDecoderTests.cs') diff --git a/IrcTokens/Tests/StatefulDecoderTests.cs b/IrcTokens/Tests/StatefulDecoderTests.cs index e0c2143..3e6a078 100644 --- a/IrcTokens/Tests/StatefulDecoderTests.cs +++ b/IrcTokens/Tests/StatefulDecoderTests.cs @@ -20,7 +20,7 @@ namespace IrcTokens.Tests public void TestPartial() { var lines = _decoder.Push("PRIVMSG "); - Assert.AreEqual(new List(), lines); + Assert.AreEqual(0, lines.Count); lines = _decoder.Push("#channel hello\r\n"); Assert.AreEqual(1, lines.Count); @@ -32,8 +32,7 @@ namespace IrcTokens.Tests [TestMethod] public void TestMultiple() { - _decoder.Push("PRIVMSG #channel1 hello\r\n"); - var lines = _decoder.Push("PRIVMSG #channel2 hello\r\n"); + var lines = _decoder.Push("PRIVMSG #channel1 hello\r\nPRIVMSG #channel2 hello\r\n"); Assert.AreEqual(2, lines.Count); var line1 = new Line("PRIVMSG #channel1 hello"); @@ -45,21 +44,21 @@ namespace IrcTokens.Tests [TestMethod] public void TestEncoding() { - var iso8859 = Encoding.GetEncodings().Single(ei => ei.Name == "iso-8859-1"); + var iso8859 = Encoding.GetEncoding("iso-8859-1"); _decoder = new StatefulDecoder {Encoding = iso8859}; - var lines = _decoder.Push("PRIVMSG #channel :hello Č\r\n"); - var line = new Line("PRIVMSG #channel :hello Č"); - Assert.AreEqual(line, lines[0]); + var lines = _decoder.Push(iso8859.GetBytes("PRIVMSG #channel :hello Ç\r\n")); + var line = new Line("PRIVMSG #channel :hello Ç"); + Assert.IsTrue(line.Equals(lines[0])); } [TestMethod] public void TestEncodingFallback() { - var latin1 = Encoding.GetEncodings().Single(ei => ei.Name == "latin-1"); - _decoder = new StatefulDecoder {Fallback = latin1}; - var lines = _decoder.Push("PRIVMSG #channel hélló\r\n"); + var latin1 = Encoding.GetEncoding("iso-8859-1"); + _decoder = new StatefulDecoder {Encoding = null, Fallback = latin1}; + var lines = _decoder.Push(latin1.GetBytes("PRIVMSG #channel hélló\r\n")); Assert.AreEqual(1, lines.Count); - Assert.AreEqual(new Line("PRIVMSG #channel hélló"), lines[0]); + Assert.IsTrue(new Line("PRIVMSG #channel hélló").Equals(lines[0])); } [TestMethod] @@ -84,14 +83,5 @@ namespace IrcTokens.Tests _decoder.Clear(); Assert.AreEqual(string.Empty, _decoder.Pending); } - - [TestMethod] - public void TestTagEncodingMismatch() - { - _decoder.Push("@asd=á "); - var lines = _decoder.Push("PRIVMSG #chan :á\r\n"); - Assert.AreEqual("á", lines[0].Params[0]); - Assert.AreEqual("á", lines[0].Tags["asd"]); - } } } -- cgit 1.4.1