public SmsResponseMessage ProcessUserSmsMessage(string smsNumber, string body) { var response = new SmsResponseMessage(); var parsedResult = SmsParser.Parse(body); if (parsedResult.UserCommand == UserCommandType.Join) { var joinResult = Join(smsNumber, parsedResult.SessionToJoin); response.Success = joinResult.Item1; response.Body = joinResult.Item2; } else if (parsedResult.UserCommand == UserCommandType.Leave) { var leaveResult = Leave(smsNumber); response.Success = leaveResult.Item1; response.Body = leaveResult.Item2; } else if (parsedResult.UserCommand == UserCommandType.Response) { var session = GetSessionIdBySms(smsNumber); var sessionResponse = session.AddResponse(smsNumber, parsedResult.FormattedString); //var sessionResponse = session.Response //determine if we want to send a message back to the user } return(response); }
public void Join(string smsBody) { var result = SmsParser.Parse(smsBody); Assert.Equal(UserCommandType.Join, result.UserCommand); Assert.Equal("one-two", result.SessionToJoin); }
public void Test() { //nothing sent.. probably can't happen. var result1 = SmsParser.Parse(""); Assert.Null(result1); //join with no session id supplied var result2 = SmsParser.Parse("join"); Assert.Null(result2); //join with half a session id? var result3 = SmsParser.Parse("join invalid"); Assert.Null(result3); }
public void Responses(string smsBody) { var result = SmsParser.Parse(smsBody); Assert.Equal(UserCommandType.Response, result.UserCommand); }
public void DontAccidentallyLeave(string smsBody) { var result = SmsParser.Parse(smsBody); Assert.Equal(UserCommandType.Response, result.UserCommand); }
public void Leave(string smsBody) { var result = SmsParser.Parse(smsBody); Assert.Equal(UserCommandType.Leave, result.UserCommand); }