switch to global usings
This commit is contained in:
parent
a7b45f1e36
commit
325b3bb30d
|
@ -29,7 +29,7 @@ internal class Client(string host, int port, string nick)
|
|||
|
||||
while (true)
|
||||
{
|
||||
while (_encoder.PendingBytes.Any())
|
||||
while (_encoder.PendingBytes.Length != 0)
|
||||
{
|
||||
foreach (var line in _encoder.Pop(_socket.Send(_encoder.PendingBytes)))
|
||||
Console.WriteLine($"> {line.Format()}");
|
||||
|
|
|
@ -17,6 +17,16 @@
|
|||
<ProjectReference Include="..\IRCTokens\IRCTokens.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="IRCTokens" />
|
||||
<Using Include="IRCStates" />
|
||||
<Using Include="System" />
|
||||
<Using Include="System.Collections.Generic" />
|
||||
<Using Include="System.Linq" />
|
||||
<Using Include="System.Text" />
|
||||
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Tokenization\Data\msg-join.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using IRCStates;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.State;
|
||||
|
||||
namespace IRCSharp.Tests.State
|
||||
[TestClass]
|
||||
public class Cap
|
||||
{
|
||||
[TestClass]
|
||||
public class Cap
|
||||
{
|
||||
private Server _server;
|
||||
|
||||
[TestInitialize]
|
||||
|
@ -127,5 +123,4 @@ namespace IRCSharp.Tests.State
|
|||
CollectionAssert.AreEqual(new Dictionary<string, string>(), _server.AvailableCaps);
|
||||
CollectionAssert.AreEqual(new List<string>(), _server.AgreedCaps);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,8 @@
|
|||
using IRCStates;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.State;
|
||||
|
||||
namespace IRCSharp.Tests.State
|
||||
[TestClass]
|
||||
public class Casemap
|
||||
{
|
||||
[TestClass]
|
||||
public class Casemap
|
||||
{
|
||||
[TestMethod]
|
||||
public void Rfc1459()
|
||||
{
|
||||
|
@ -54,5 +51,4 @@ namespace IRCSharp.Tests.State
|
|||
Assert.AreEqual("NewNickname", server.NickName);
|
||||
Assert.AreEqual("newnickname", server.NickNameLower);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using IRCStates;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.State;
|
||||
|
||||
namespace IRCSharp.Tests.State
|
||||
[TestClass]
|
||||
public class Channel
|
||||
{
|
||||
[TestClass]
|
||||
public class Channel
|
||||
{
|
||||
private Server _server;
|
||||
|
||||
[TestInitialize]
|
||||
|
@ -103,16 +97,16 @@ namespace IRCSharp.Tests.State
|
|||
public void QuitSelf()
|
||||
{
|
||||
_server.Parse(new("QUIT :i'm outta here"));
|
||||
Assert.IsFalse(_server.Users.Any());
|
||||
Assert.IsFalse(_server.Channels.Any());
|
||||
Assert.IsFalse(_server.Users.Count != 0);
|
||||
Assert.IsFalse(_server.Channels.Count != 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void QuitSelfWithSource()
|
||||
{
|
||||
_server.Parse(new(":nickname QUIT :i'm outta here"));
|
||||
Assert.IsFalse(_server.Users.Any());
|
||||
Assert.IsFalse(_server.Channels.Any());
|
||||
Assert.IsFalse(_server.Users.Count != 0);
|
||||
Assert.IsFalse(_server.Channels.Count != 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -197,5 +191,4 @@ namespace IRCSharp.Tests.State
|
|||
CollectionAssert.AreEqual(new Dictionary<string, ChannelUser> {{user.NickNameLower, chanUser}},
|
||||
channel.Users);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using IRCStates;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.State;
|
||||
|
||||
namespace IRCSharp.Tests.State
|
||||
[TestClass]
|
||||
public class Emit
|
||||
{
|
||||
[TestClass]
|
||||
public class Emit
|
||||
{
|
||||
private Server _server;
|
||||
|
||||
[TestInitialize]
|
||||
|
@ -113,5 +109,4 @@ namespace IRCSharp.Tests.State
|
|||
"-i"
|
||||
}, emit.Tokens);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using IRCStates;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// ReSharper disable InconsistentNaming
|
||||
namespace IRCSharp.Tests.State;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace IRCSharp.Tests.State
|
||||
[TestClass]
|
||||
public class ISupport
|
||||
{
|
||||
[TestClass]
|
||||
public class ISupport
|
||||
{
|
||||
private Server _server;
|
||||
|
||||
[TestInitialize]
|
||||
|
@ -206,5 +201,4 @@ namespace IRCSharp.Tests.State
|
|||
_server.Parse(new("005 * WATCH *"));
|
||||
Assert.AreEqual(-1, _server.ISupport.Watch);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using IRCStates;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.State;
|
||||
|
||||
namespace IRCSharp.Tests.State
|
||||
[TestClass]
|
||||
public class Mode
|
||||
{
|
||||
[TestClass]
|
||||
public class Mode
|
||||
{
|
||||
private Server _server;
|
||||
|
||||
[TestInitialize]
|
||||
|
@ -175,5 +171,4 @@ namespace IRCSharp.Tests.State
|
|||
_server.Parse(new("221 * iw"));
|
||||
CollectionAssert.AreEqual(new List<string> {"i", "w"}, _server.Modes);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using IRCStates;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.State;
|
||||
|
||||
namespace IRCSharp.Tests.State
|
||||
[TestClass]
|
||||
public class Motd
|
||||
{
|
||||
[TestClass]
|
||||
public class Motd
|
||||
{
|
||||
[TestMethod]
|
||||
public void MessageOfTheDay()
|
||||
{
|
||||
|
@ -19,5 +15,4 @@ namespace IRCSharp.Tests.State
|
|||
CollectionAssert.AreEqual(new List<string> {"start of motd", "first line of motd", "second line of motd"},
|
||||
server.Motd);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,8 @@
|
|||
using IRCStates;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.State;
|
||||
|
||||
namespace IRCSharp.Tests.State
|
||||
[TestClass]
|
||||
public class Sasl
|
||||
{
|
||||
[TestClass]
|
||||
public class Sasl
|
||||
{
|
||||
private Server _server;
|
||||
|
||||
[TestInitialize]
|
||||
|
@ -34,5 +31,4 @@ namespace IRCSharp.Tests.State
|
|||
Assert.AreEqual("host1", _server.HostName);
|
||||
Assert.IsTrue(string.IsNullOrEmpty(_server.Account));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,8 @@
|
|||
using IRCStates;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.State;
|
||||
|
||||
namespace IRCSharp.Tests.State
|
||||
[TestClass]
|
||||
public class User
|
||||
{
|
||||
[TestClass]
|
||||
public class User
|
||||
{
|
||||
private Server _server;
|
||||
|
||||
[TestInitialize]
|
||||
|
@ -294,5 +291,4 @@ namespace IRCSharp.Tests.State
|
|||
Assert.AreEqual("new now know how", _server.RealName);
|
||||
Assert.AreEqual("tyrannosaurus hex", user.RealName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,8 @@
|
|||
using IRCStates;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.State;
|
||||
|
||||
namespace IRCSharp.Tests.State
|
||||
[TestClass]
|
||||
public class Who
|
||||
{
|
||||
[TestClass]
|
||||
public class Who
|
||||
{
|
||||
private Server _server;
|
||||
|
||||
[TestInitialize]
|
||||
|
@ -57,5 +54,4 @@ namespace IRCSharp.Tests.State
|
|||
Assert.IsNull(user.Account);
|
||||
Assert.AreEqual(user.Account, _server.Account);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using YamlDotNet.Serialization;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace IRCSharp.Tests.Tokenization.Data
|
||||
namespace IRCSharp.Tests.Tokenization.Data;
|
||||
|
||||
public class JoinModel
|
||||
{
|
||||
public class JoinModel
|
||||
{
|
||||
public List<Test> Tests { get; set; }
|
||||
|
||||
public class Test
|
||||
|
@ -26,5 +25,4 @@ namespace IRCSharp.Tests.Tokenization.Data
|
|||
|
||||
public List<string> Params { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
namespace IRCSharp.Tests.Tokenization.Data;
|
||||
|
||||
namespace IRCSharp.Tests.Tokenization.Data
|
||||
public class SplitModel
|
||||
{
|
||||
public class SplitModel
|
||||
{
|
||||
public List<Test> Tests { get; set; }
|
||||
|
||||
public class Test
|
||||
|
@ -11,5 +9,4 @@ namespace IRCSharp.Tests.Tokenization.Data
|
|||
public string Input { get; set; }
|
||||
public JoinModel.Atoms Atoms { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,8 @@
|
|||
using System;
|
||||
using IRCTokens;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.Tokenization;
|
||||
|
||||
namespace IRCSharp.Tests.Tokenization
|
||||
[TestClass]
|
||||
public class Format
|
||||
{
|
||||
[TestClass]
|
||||
public class Format
|
||||
{
|
||||
[TestMethod]
|
||||
public void Tags()
|
||||
{
|
||||
|
@ -15,7 +11,7 @@ namespace IRCSharp.Tests.Tokenization
|
|||
Tags = new() {{"id", "\\" + " " + ";" + "\r\n"}}
|
||||
}.Format();
|
||||
|
||||
Assert.AreEqual("@id=\\\\\\s\\:\\r\\n PRIVMSG #channel hello", line);
|
||||
Assert.AreEqual(@"@id=\\\s\:\r\n PRIVMSG #channel hello", line);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -101,5 +97,4 @@ namespace IRCSharp.Tests.Tokenization
|
|||
{
|
||||
Assert.ThrowsException<ArgumentException>(() => { new Line("PRIVMSG", ":#channel", "hello").Format(); });
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,8 @@
|
|||
using IRCTokens;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.Tokenization;
|
||||
|
||||
namespace IRCSharp.Tests.Tokenization
|
||||
[TestClass]
|
||||
public class Hostmask
|
||||
{
|
||||
[TestClass]
|
||||
public class Hostmask
|
||||
{
|
||||
[TestMethod]
|
||||
public void FullHostmask()
|
||||
{
|
||||
|
@ -61,5 +58,4 @@ namespace IRCSharp.Tests.Tokenization
|
|||
Assert.IsNull(line.Hostmask.UserName);
|
||||
Assert.IsNull(line.Hostmask.NickName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +1,14 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using IRCSharp.Tests.Tokenization.Data;
|
||||
using IRCTokens;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using YamlDotNet.Serialization;
|
||||
using YamlDotNet.Serialization.NamingConventions;
|
||||
|
||||
namespace IRCSharp.Tests.Tokenization
|
||||
namespace IRCSharp.Tests.Tokenization;
|
||||
|
||||
[TestClass]
|
||||
public class Parser
|
||||
{
|
||||
[TestClass]
|
||||
public class Parser
|
||||
{
|
||||
private static T LoadYaml<T>(string path)
|
||||
{
|
||||
var deserializer = new DeserializerBuilder()
|
||||
|
@ -33,7 +30,7 @@ namespace IRCSharp.Tests.Tokenization
|
|||
$"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,
|
||||
CollectionAssert.AreEqual(atoms.Params ?? [], tokens.Params,
|
||||
$"params failed on: '{test.Input}'");
|
||||
}
|
||||
}
|
||||
|
@ -52,5 +49,4 @@ namespace IRCSharp.Tests.Tokenization
|
|||
Assert.IsTrue(test.Matches.Contains(line), test.Description);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using IRCTokens;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.Tokenization;
|
||||
|
||||
namespace IRCSharp.Tests.Tokenization
|
||||
[TestClass]
|
||||
public class StatefulDecoder
|
||||
{
|
||||
[TestClass]
|
||||
public class StatefulDecoder
|
||||
{
|
||||
private IRCTokens.StatefulDecoder _decoder;
|
||||
|
||||
[TestInitialize]
|
||||
|
@ -85,5 +80,4 @@ namespace IRCSharp.Tests.Tokenization
|
|||
_decoder.Clear();
|
||||
Assert.AreEqual(string.Empty, _decoder.Pending);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,8 @@
|
|||
using System.Text;
|
||||
using IRCTokens;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.Tokenization;
|
||||
|
||||
namespace IRCSharp.Tests.Tokenization
|
||||
[TestClass]
|
||||
public class StatefulEncoder
|
||||
{
|
||||
[TestClass]
|
||||
public class StatefulEncoder
|
||||
{
|
||||
private IRCTokens.StatefulEncoder _encoder;
|
||||
|
||||
[TestInitialize]
|
||||
|
@ -81,5 +77,4 @@ namespace IRCSharp.Tests.Tokenization
|
|||
_encoder.Push(new("PRIVMSG #channel :hello Ç"));
|
||||
CollectionAssert.AreEqual(iso8859.GetBytes("PRIVMSG #channel :hello Ç\r\n"), _encoder.PendingBytes);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using IRCTokens;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace IRCSharp.Tests.Tokenization;
|
||||
|
||||
namespace IRCSharp.Tests.Tokenization
|
||||
[TestClass]
|
||||
public class Tokenization
|
||||
{
|
||||
[TestClass]
|
||||
public class Tokenization
|
||||
{
|
||||
[TestMethod]
|
||||
public void TagsMissing()
|
||||
{
|
||||
|
@ -41,7 +35,7 @@ namespace IRCSharp.Tests.Tokenization
|
|||
public void TagsOverlap()
|
||||
{
|
||||
var line = new Line(@"@id=1\\\s\\s PRIVMSG #channel");
|
||||
Assert.AreEqual("1\\ \\s", line.Tags["id"]);
|
||||
Assert.AreEqual(@"1\ \s", line.Tags["id"]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -122,13 +116,12 @@ namespace IRCSharp.Tests.Tokenization
|
|||
public void NulByte()
|
||||
{
|
||||
var decoder = new IRCTokens.StatefulDecoder();
|
||||
var bytes = Encoding.UTF8.GetBytes(":nick!user@host PRIVMSG #channel :hello")
|
||||
.Concat(Encoding.UTF8.GetBytes("\0"))
|
||||
.Concat(Encoding.UTF8.GetBytes("world"))
|
||||
var bytes = ":nick!user@host PRIVMSG #channel :hello"u8.ToArray()
|
||||
.Concat("\0"u8.ToArray())
|
||||
.Concat("world"u8.ToArray())
|
||||
.ToArray();
|
||||
var line = decoder.Push(bytes, bytes.Length).First();
|
||||
|
||||
CollectionAssert.AreEqual(new List<string> {"#channel", "hello"}, line.Params);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -212,10 +212,10 @@ namespace IRCTokens
|
|||
foreach (var p in withoutLast)
|
||||
{
|
||||
if (p.Contains(' ', StringComparison.Ordinal))
|
||||
throw new ArgumentException(@"non-last parameters cannot have spaces", p);
|
||||
throw new ArgumentException("non-last parameters cannot have spaces", p);
|
||||
|
||||
if (p.StartsWith(':'))
|
||||
throw new ArgumentException(@"non-last parameters cannot start with colon", p);
|
||||
throw new ArgumentException("non-last parameters cannot start with colon", p);
|
||||
}
|
||||
|
||||
outs.AddRange(withoutLast);
|
||||
|
|
Loading…
Reference in New Issue