public void TryMatch_Fail() { string[] actual; var test = "Testing out tryMatch out"; Assert.IsFalse(TRegex.TryMatch(test, "fail", out actual)); Assert.IsNull(actual); }
public void TryMatch() { string[] actual; var test = "Testing out tryMatch out"; var expected = new[] { "out" }; Assert.IsTrue(TRegex.TryMatch(test, "out", out actual)); CollectionAssert.AreEqual(expected, actual); }
void onChat(Instance bot, Avatar user, string message) { lock ( mutex ) { string[] match; string[] wrongMatch; if (!TRegex.TryMatch(message, entryInPlay.Answer, out match)) { return; } if (entryInPlay.Wrong != null && TRegex.TryMatch(message, entryInPlay.Wrong, out wrongMatch)) { Log.Debug(tag, "Given answer '{0}' by {1} matched, but turned out to be wrong; rejecting", wrongMatch[0], user.Name); return; } gameEnd(); var welldone = welldones.Skip(VPServices.Rand.Next(welldones.Length)).Take(1).Single(); if (match[0].IEquals(entryInPlay.CanonicalAnswer)) { app.Bot.ConsoleBroadcast(ChatEffect.Bold, VPServices.ColorInfo, "Triviamaster", msgAccepted, entryInPlay.CanonicalAnswer, welldone, user.Name); } else { app.Bot.ConsoleBroadcast(ChatEffect.Bold, VPServices.ColorInfo, "Triviamaster", msgAcceptedFrom, entryInPlay.CanonicalAnswer, match[0], welldone, user.Name); } Log.Debug(tag, "Correct answer '{0}' by {1}", match[0], user.Name); awardPoint(user.Name); } }