public void GetById() { _slackChannelRepository.AddSlackChannel(slackChannelDetails); var slackChannel = _slackChannelRepository.GetById(_stringConstant.ChannelIdForTest); Assert.Equal(slackChannel.ChannelId, _stringConstant.ChannelIdForTest); }
public void SlackAddChannel() { slackEvent.Event.Channel = channel; _oAuthLoginRepository.SlackChannelAdd(slackEvent); var channelAdded = _slackChannelRepository.GetById(slackEvent.Event.Channel.ChannelId); Assert.Equal(channelAdded.Name, slackEvent.Event.Channel.Name); }
public async Task <string> ProcessMessages(string userId, string channelId, string message) { string replyText = string.Empty; SlackUserDetails user = _slackUserDetails.GetById(userId); SlackChannelDetails channel = _slackChannelRepository.GetById(channelId); //the command is split to individual words //commnads ex: "scrum time", "later @userId" var messageArray = message.Split(null); if (user != null && String.Compare(message, _stringConstant.ScrumHelp, true) == 0) { replyText = _stringConstant.ScrumHelpMessage; } else if (user != null && channel != null) { //commands could be"scrum time" or "scrum halt" or "scrum resume" if (String.Compare(message, _stringConstant.ScrumTime, true) == 0 || String.Compare(message, _stringConstant.ScrumHalt, true) == 0 || String.Compare(message, _stringConstant.ScrumResume, true) == 0) { replyText = await Scrum(channel.Name, user.Name, messageArray[1].ToLower()); } //a particular employee is on leave, getting marked as later or asked question again //commands would be "leave @userId" else if ((String.Compare(messageArray[0], _stringConstant.Leave, true) == 0) && messageArray.Length == 2) { int fromIndex = message.IndexOf("<@") + "<@".Length; int toIndex = message.LastIndexOf(">"); if (toIndex > 0) { try { //the userId is fetched string applicantId = message.Substring(fromIndex, toIndex - fromIndex); //fetch the user of the given userId SlackUserDetails applicant = _slackUserDetails.GetById(applicantId); if (applicant != null) { string applicantName = applicant.Name; replyText = await Leave(channel.Name, user.Name, applicantName); } else { replyText = _stringConstant.NotAUser; } } catch (Exception) { replyText = _stringConstant.ScrumHelpMessage; } } else { replyText = await AddScrumAnswer(user.Name, message, channel.Name); } } //all other texts else { replyText = await AddScrumAnswer(user.Name, message, channel.Name); } } //If channel is not registered in the database else if (user != null) { //If channel is not registered in the database and the command encountered is "add channel channelname" if (channel == null && String.Compare(messageArray[0], _stringConstant.Add, true) == 0 && String.Compare(messageArray[1], _stringConstant.Channel, true) == 0) { replyText = AddChannelManually(messageArray[2], user.Name, channelId).Result; } else { replyText = _stringConstant.ChannelAddInstruction; } } else if (user == null) { SlackBotUserDetail botUser = _slackBotUserDetail.FirstOrDefault(x => x.UserId == userId); if (botUser == null) { replyText = _stringConstant.NoSlackDetails; } } return(replyText); }