about summary refs log tree commit diff
path: root/IrcTokens/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'IrcTokens/Tests')
-rw-r--r--IrcTokens/Tests/ParserTests.cs4
-rw-r--r--IrcTokens/Tests/StatefulDecoderTests.cs30
-rw-r--r--IrcTokens/Tests/StatefulEncoderTests.cs14
3 files changed, 20 insertions, 28 deletions
diff --git a/IrcTokens/Tests/ParserTests.cs b/IrcTokens/Tests/ParserTests.cs
index 502b6d6..ad734cf 100644
--- a/IrcTokens/Tests/ParserTests.cs
+++ b/IrcTokens/Tests/ParserTests.cs
@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using System.Globalization;
 using System.IO;
 using IrcTokens.Tests.Data;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -27,7 +28,8 @@ namespace IrcTokens.Tests
                 var tokens = new Line(test.Input);
                 var atoms = test.Atoms;
 
-                Assert.AreEqual(atoms.Verb.ToUpper(), tokens.Command, $"command failed on: '{test.Input}'");
+                Assert.AreEqual(atoms.Verb.ToUpper(CultureInfo.InvariantCulture), tokens.Command,
+                    $"command failed on: '{test.Input}'");
                 Assert.AreEqual(atoms.Source, tokens.Source, $"source failed on: '{test.Input}'");
                 CollectionAssert.AreEqual(atoms.Tags, tokens.Tags, $"tags failed on: '{test.Input}'");
                 CollectionAssert.AreEqual(atoms.Params ?? new List<string>(), tokens.Params, $"params failed on: '{test.Input}'");
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<string>(), 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"]);
-        }
     }
 }
diff --git a/IrcTokens/Tests/StatefulEncoderTests.cs b/IrcTokens/Tests/StatefulEncoderTests.cs
index 4732573..477b38d 100644
--- a/IrcTokens/Tests/StatefulEncoderTests.cs
+++ b/IrcTokens/Tests/StatefulEncoderTests.cs
@@ -20,7 +20,7 @@ namespace IrcTokens.Tests
         {
             var line = new Line("PRIVMSG #channel hello");
             _encoder.Push(line);
-            Assert.AreEqual("PRIVMSG #channel hello\r\n", _encoder.Pending);
+            Assert.AreEqual("PRIVMSG #channel hello\r\n", _encoder.Pending());
         }
 
         [TestMethod]
@@ -29,7 +29,7 @@ namespace IrcTokens.Tests
             var line = new Line("PRIVMSG #channel hello");
             _encoder.Push(line);
             _encoder.Pop("PRIVMSG #channel hello".Length);
-            Assert.AreEqual("\r\n", _encoder.Pending);
+            Assert.AreEqual("\r\n", _encoder.Pending());
         }
 
         [TestMethod]
@@ -57,16 +57,16 @@ namespace IrcTokens.Tests
         {
             _encoder.Push(new Line("PRIVMSG #channel hello"));
             _encoder.Clear();
-            Assert.AreEqual(string.Empty, _encoder.Pending);
+            Assert.AreEqual(string.Empty, _encoder.Pending());
         }
 
         [TestMethod]
         public void TestEncoding()
         {
-            var iso88592 = Encoding.GetEncodings().Single(ei => ei.Name == "iso-8859-2");
-            _encoder = new StatefulEncoder {Encoding = iso88592};
-            _encoder.Push(new Line("PRIVMSG #channel :hello Č"));
-            Assert.AreEqual("PRIVMSG #channel :hello Č\r\n", _encoder.Pending);
+            var iso8859 = Encoding.GetEncoding("iso-8859-1");
+            _encoder = new StatefulEncoder {Encoding = iso8859};
+            _encoder.Push(new Line("PRIVMSG #channel :hello Ç"));
+            CollectionAssert.AreEqual(iso8859.GetBytes("PRIVMSG #channel :hello Ç\r\n"), _encoder.PendingBytes);
         }
     }
 }