public async void ScrumInitiateNoProject()
        {
            slackChannelDetails.Name = _stringConstant.UserNameForTest;
            _slackChannelReposiroty.AddSlackChannel(slackChannelDetails);
            _slackUserRepository.AddSlackUser(slackUserDetails);

            UserLoginInfo info = new UserLoginInfo(_stringConstant.PromactStringName, _stringConstant.AccessTokenForTest);
            await _userManager.CreateAsync(user);

            await _userManager.AddLoginAsync(user.Id, info);

            var projectResponse   = Task.FromResult(_stringConstant.ProjectDetailsFromOauth);
            var projectRequestUrl = string.Format("{0}", _stringConstant.GroupName);

            _mockHttpClient.Setup(x => x.GetAsync(_stringConstant.ProjectUrl, projectRequestUrl, _stringConstant.AccessTokenForTest)).Returns(projectResponse);

            var msg = await _scrumBotRepository.ProcessMessages(_stringConstant.StringIdForTest, _stringConstant.SlackChannelIdForTest, _stringConstant.ScrumTime);

            Assert.Equal(_stringConstant.NoProjectFound, msg);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Used to add channel manually by command "add channel channelname"
        /// </summary>
        /// <param name="channelName"></param>
        /// <param name="channelId"></param>
        /// <param name="username"></param>
        /// <returns>status message</returns>
        private async Task <string> AddChannelManually(string channelName, string username, string channelId)
        {
            string returnMsg = string.Empty;

            //Checks whether channelId starts with "G". This is done inorder to make sure that only private channels are added manually
            if (IsPrivateChannel(channelId))
            {
                // getting user name from user's slack name
                var applicationUser = _applicationUser.FirstOrDefault(x => x.SlackUserName == username);
                // getting access token for that user
                if (applicationUser != null)
                {
                    // get access token of user for promact oauth server
                    string accessToken = await _attachmentRepository.AccessToken(applicationUser.UserName);

                    //get the project details of the given channel name
                    ProjectAc project = await _projectUser.GetProjectDetails(channelName, accessToken);

                    //add channel details only if the channel has been registered as project in OAuth server
                    if (project != null && project.Id > 0)
                    {
                        SlackChannelDetails channel = new SlackChannelDetails();
                        channel.ChannelId = channelId;
                        channel.CreatedOn = DateTime.UtcNow;
                        channel.Deleted   = false;
                        channel.Name      = channelName;
                        _slackChannelRepository.AddSlackChannel(channel);
                        returnMsg = _stringConstant.ChannelAddSuccess;
                    }
                    else
                    {
                        returnMsg = _stringConstant.ProjectNotInOAuth;
                    }
                }
                else
                {
                    // if user doesn't exist then this message will be shown to user
                    returnMsg = _stringConstant.YouAreNotInExistInOAuthServer;
                }
            }
            else
            {
                return(_stringConstant.OnlyPrivateChannel);
            }

            return(returnMsg);
        }
 public void SlackChannelAdd()
 {
     _slackChannelRepository.AddSlackChannel(slackChannelDetails);
     Assert.Equal(slackChannelDetails.ChannelId, _stringConstant.ChannelIdForTest);
 }