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); }
public void UnexpectedValue_FromString_ArgumentExceptionIsThrown() { Assert.Throws <ArgumentException>(() => RequestSourceBuilder.FromString("§")); }
public void nullValue_FromString_ArgumentExceptionIsThrown() { Assert.Throws <ArgumentException>(() => RequestSourceBuilder.FromString(null)); }
public void LocalText_FromString_MappedToWhisper() { RequestSource actual = RequestSourceBuilder.FromString(""); actual.Should().BeEquivalentTo(RequestSource.LOCAL); }
public void TradeText_FromString_MappedToWhisper() { RequestSource actual = RequestSourceBuilder.FromString("$"); actual.Should().BeEquivalentTo(RequestSource.TRADE); }
public void GuildText_FromString_MappedToWhisper() { RequestSource actual = RequestSourceBuilder.FromString("&"); actual.Should().BeEquivalentTo(RequestSource.GUILD); }
public void WhisperText_FromString_MappedToWhisper() { RequestSource actual = RequestSourceBuilder.FromString("@From "); actual.Should().BeEquivalentTo(RequestSource.WHISPER); }