about summary refs log tree commit diff
path: root/IRCSharp.Tests/State/Who.cs
blob: 2220b12f7b8ebddab4fc83d08374f9d81ae74a1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using IRCStates;
using IRCTokens;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace IRCSharp.Tests.State
{
    [TestClass]
    public class Who
    {
        private Server _server;

        [TestInitialize]
        public void TestInitialize()
        {
            _server = new Server("test");
            _server.Parse(new Line("001 nickname"));
            _server.Parse(new Line(":nickname JOIN #chan"));
        }

        [TestMethod]
        public void WhoResponse()
        {
            _server.Parse(new Line("352 * #chan user host server nickname * :0 real"));
            var user = _server.Users["nickname"];

            Assert.AreEqual("user", user.UserName);
            Assert.AreEqual("host", _server.HostName);
            Assert.AreEqual("real", user.RealName);

            Assert.AreEqual(user.UserName, _server.UserName);
            Assert.AreEqual(user.HostName, _server.HostName);
            Assert.AreEqual(user.RealName, _server.RealName);
        }

        [TestMethod]
        public void Whox()
        {
            _server.Parse(new Line($"354 * {Server.WhoType} user realip host nickname account :real"));
            var user = _server.Users["nickname"];

            Assert.AreEqual("user", user.UserName);
            Assert.AreEqual("host", user.HostName);
            Assert.AreEqual("real", user.RealName);
            Assert.AreEqual("account", user.Account);

            Assert.AreEqual(user.UserName, _server.UserName);
            Assert.AreEqual(user.HostName, _server.HostName);
            Assert.AreEqual(user.RealName, _server.RealName);
            Assert.AreEqual(user.Account, _server.Account);
        }

        [TestMethod]
        public void WhoxNoAccount()
        {
            _server.Parse(new Line($"354 * {Server.WhoType} user realip host nickname 0 :real"));
            var user = _server.Users["nickname"];

            Assert.IsNull(user.Account);
            Assert.AreEqual(user.Account, _server.Account);
        }
    }
}