コード例 #1
0
        /// <summary>
        /// Used to link Slack Channel to OAuth Project - JJ
        /// </summary>
        /// <param name="slackChannelId">slack channel id from which message is send</param>
        /// <param name="givenProjectName">the project name mentioned in the slack message</param>
        /// <param name="project">OAuth Project of the given name</param>
        /// <returns>status message</returns>
        private async Task <string> LinkAsync(string slackChannelId, string givenProjectName, ProjectAc project)
        {
            if (project.IsActive)
            {
                SlackChannelDetails alreadyLinkedChannel = await _slackChannelRepository.FetchChannelByProjectIdAsync(project.Id);

                if (alreadyLinkedChannel == null)
                {
                    //add the project id to the slack channel
                    SlackChannelDetails slackChannel = await _slackChannelRepository.GetByIdAsync(slackChannelId);

                    if (slackChannel.ProjectId == null)
                    {
                        _logger.Debug("\nLinkAsync method : not linked to any project yet\n");
                        slackChannel.ProjectId = project.Id;
                        await _slackChannelRepository.UpdateSlackChannelAsync(slackChannel);

                        return(string.Format(_stringConstant.ProjectLinked, givenProjectName, slackChannel.Name));
                    }
                    else
                    {
                        return(string.Format(_stringConstant.UnLinkFirst, givenProjectName));
                    }
                }
                else
                {
                    return(_stringConstant.AlreadyLinked);
                }
            }
            else
            {
                return(_stringConstant.InActiveProject);
            }
        }
        public async Task GetByIdAsync()
        {
            await _slackChannelRepository.AddSlackChannelAsync(slackChannelDetails);

            SlackChannelDetails slackChannel = await _slackChannelRepository.GetByIdAsync(_stringConstant.ChannelIdForTest);

            Assert.Equal(slackChannel.ChannelId, _stringConstant.ChannelIdForTest);
        }
コード例 #3
0
        public async Task SlackAddChannelAsync()
        {
            slackEvent.Event.Channel = channel;
            await _oAuthLoginRepository.SlackChannelAddAsync(slackEvent);

            var channelAdded = await _slackChannelRepository.GetByIdAsync(slackEvent.Event.Channel.ChannelId);

            Assert.Equal(channelAdded.Name, slackEvent.Event.Channel.Name);
        }