private void LogBot(string tag, string text) { text = TextUtils.Clean(text); txtLog1.Invoke((Action) delegate { txtLog1.Text += string.Format("\t[{0}] {1}{2}", tag, text, Environment.NewLine); txtLog1.SelectionStart = txtLog1.Text.Length; txtLog1.ScrollToCaret(); }); }
private void Validate(Bot bot, string userId, string text, string custom_text, params string[] parameters) { LogUser(userId, text); string id = ""; if (!string.IsNullOrEmpty(text)) { id = bot.SendActivityToBot(userId, text); } else if (!string.IsNullOrEmpty(custom_text)) { custom_text = custom_text.Replace("default-user", userId); id = bot.SendCustomActivityToBot(custom_text); } Activities data = bot.ReceiveActivitiesFromBot(id); int index = 0; foreach (Activity activity in data.activities) { LogBot("Bot", activity.text); if (data.activities.Length >= 100) { // For some unknown reason, in some cases, the id is 0000000 or 0000001 // so it's returning all the messages. Skipping the behavior for now return; } if (data.activities.Length != parameters.Length) { CopyToClipboard(text + custom_text + JsonConvert.SerializeObject(data)); throw new StateException(string.Format("Activities length doesn't match.\n\nReceived: {0}\nExpected: {1}", data.activities.Length, parameters.Length)); } if (!TextUtils.Clean(activity.text).Equals(TextUtils.Clean(parameters[index]))) { CopyToClipboard(text + custom_text + JsonConvert.SerializeObject(data)); throw new StateException(string.Format("Text doesn't match.\n\nReceived: {0}\nExpected: {1}", activity.text, parameters[index])); } index++; } UpdateUI(); }