public void GetBrithdaysByMonthTest() { var obj = BirthdayDoamin.GetBirthdays(); IEnumerable <Birthday> lists = BirthdayDoamin.GetBrithdaysByMonth(2016, 12); Assert.IsNotNull(lists); }
public void OnTextRequestTest() { BirthdayDoamin.TransformString(BirthdayDoamin.GetBrithdaysByMonth(DateTime.Now.Year, 12)); //var requestMessageText = new RequestMessageText(); //requestMessageText.Content = "m12"; //ResponseMessageText callback = (ResponseMessageText)(customMessageHandler.OnTextOrEventRequest(requestMessageText)); //Assert.IsNotNull(callback.Content); }
public override IResponseMessageBase OnTextRequest(RequestMessageText requestMessage) { //TODO:这里的逻辑可以交给Service处理具体信息,参考OnLocationRequest方法或/Service/LocationSercice.cs var responseMessage = CreateResponseMessage <ResponseMessageText>(); if (requestMessage.Content.Equals("help")) { responseMessage.Content = TextConstants.Help; } else if (requestMessage.Content.Equals("生日")) { responseMessage.Content = BirthdayDoamin.TransformString(BirthdayDoamin.GetRecentBrithdays(31)); } else if (Regex.IsMatch(requestMessage.Content, @"^生日(\d+)$")) { int days = int.Parse(Regex.Match(requestMessage.Content, @"^生日(\d+)$").Groups[1].Value); responseMessage.Content = BirthdayDoamin.TransformString(BirthdayDoamin.GetRecentBrithdays(days)); } else if (Regex.IsMatch(requestMessage.Content, @"^m(0?[[1-9]|1[0-2])$")) { int month = int.Parse(Regex.Match(requestMessage.Content, @"^m(0?[[1-9]|1[0-2])$").Groups[1].Value); responseMessage.Content = BirthdayDoamin.TransformString(BirthdayDoamin.GetBrithdaysByMonth(DateTime.Now.Year, month)); } else if (Regex.IsMatch(requestMessage.Content, @"^m(\d{4})\.(0?[[1-9]|1[0-2])$")) { Match match = Regex.Match(requestMessage.Content, @"^m(\d{4})\.(0?[[1-9]|1[0-2])$"); int year = int.Parse(match.Groups[1].Value); int month = int.Parse(match.Groups[2].Value); responseMessage.Content = BirthdayDoamin.TransformString(BirthdayDoamin.GetBrithdaysByMonth(year, month)); } else { responseMessage.Content = string.Format( "您刚才发送了文字信息:{0}", requestMessage.Content); } return(responseMessage); }