コード例 #1
0
ファイル: LogFileParser.cs プロジェクト: Xezz/PoE-PartyInvite
        public PartyRequest ParseLine(string line)
        {
            Match        match  = regex.Match(line);
            PartyRequest result = null;

            if (match.Success)
            {
                /**
                 * 1 Year/Month/Day Hour:Minute:Seconds
                 * 2 Source
                 * 3 Guild (maybe null)
                 * 4 Character
                 * 5 Message
                 * */
                result = new PartyRequest(new InviteExecutor());
                if (match.Groups[3].Length > 1)
                {
                    result.GuildName = match.Groups[3].Captures[0].Value.Trim();
                }
                else
                {
                    result.GuildName = "";
                }
                result.CharacterName  = match.Groups[4].Captures[0].Value;
                result.RequestDate    = DateTime.Parse(match.Groups[1].Captures[0].Value);
                result.RequestSource  = RequestSourceBuilder.FromString(match.Groups[2].Captures[0].Value);
                result.RequestMessage = match.Groups[5].Captures[0].Value;
            }
            return(result);
        }
コード例 #2
0
 public void UnexpectedValue_FromString_ArgumentExceptionIsThrown()
 {
     Assert.Throws <ArgumentException>(() => RequestSourceBuilder.FromString("§"));
 }
コード例 #3
0
 public void nullValue_FromString_ArgumentExceptionIsThrown()
 {
     Assert.Throws <ArgumentException>(() => RequestSourceBuilder.FromString(null));
 }
コード例 #4
0
        public void LocalText_FromString_MappedToWhisper()
        {
            RequestSource actual = RequestSourceBuilder.FromString("");

            actual.Should().BeEquivalentTo(RequestSource.LOCAL);
        }
コード例 #5
0
        public void TradeText_FromString_MappedToWhisper()
        {
            RequestSource actual = RequestSourceBuilder.FromString("$");

            actual.Should().BeEquivalentTo(RequestSource.TRADE);
        }
コード例 #6
0
        public void GuildText_FromString_MappedToWhisper()
        {
            RequestSource actual = RequestSourceBuilder.FromString("&");

            actual.Should().BeEquivalentTo(RequestSource.GUILD);
        }
コード例 #7
0
        public void WhisperText_FromString_MappedToWhisper()
        {
            RequestSource actual = RequestSourceBuilder.FromString("@From ");

            actual.Should().BeEquivalentTo(RequestSource.WHISPER);
        }