Example #1
0
        public void CanParseKick()
        {
            var logFile =
            @"--- Log opened Tue Dec 24 00:26:23 2013
            04:28 -!- :owl was kicked from [email protected] by [email protected] [:sweetiestare:]";

            var expected = new KickedMessage(new DateTime(2013, 12, 24, 4, 28, 0), ":owl", ":sweetiestare:");
            var logMessage = new LogParser().Parse(logFile).Cast<KickedMessage>().Single();

            Assert.Equal(expected, logMessage);
        }
Example #2
0
 public static bool TryCreate(string input, DateTime currentTime, out KickedMessage message)
 {
     var match = regex.Match(input);
     if (match.Success)
     {
         var hours = int.Parse(match.Groups[1].Value);
         var minutes = int.Parse(match.Groups[2].Value);
         var time = new DateTime(currentTime.Year, currentTime.Month, currentTime.Day, hours, minutes, 0);
         var speaker = match.Groups[3].Value;
         var text = match.Groups[4].Value;
         message = new KickedMessage(time, speaker, text);
         return true;
     }
     message = null;
     return false;
 }