public HandleMessageRequestHander(IMediator mediator, BotRepository repository, IcebreakerBot bot, TelemetryClient telemetryClient) { _mediator = mediator; _repository = repository; _bot = bot; _telemetryClient = telemetryClient; }
public IceBreakerBotTests() { this.botAdapter = new TestAdapter(Channels.Msteams) { Conversation = { Conversation = new ConversationAccount { ConversationType = "channel", }, }, }; ConfigurationManager.AppSettings[DisableTenantFilterKey] = true.ToString().ToLower(); this.telemetryClient = new TelemetryClient(); this.conversationHelper = new ConversationHelperMock(); this.dataProvider = new Mock <IBotDataProvider>(); this.dataProvider.Setup(x => x.GetInstalledTeamAsync(It.IsAny <string>())) .Returns(() => Task.FromResult(new TeamInstallInfo())); this.sut = new IcebreakerBot(this.dataProvider.Object, this.conversationHelper, MicrosoftAppCredentials.Empty, this.telemetryClient); this.userAccount = new TeamsChannelAccount { Id = Guid.NewGuid().ToString(), Properties = JObject.FromObject(new { Id = Guid.NewGuid().ToString() }) }; this.botAccount = new TeamsChannelAccount { Id = "bot", Properties = JObject.FromObject(new { Id = "bot" }) }; this.teamsChannelData = new TeamsChannelData { Team = new TeamInfo { Id = "TeamId", }, Tenant = new TenantInfo(), }; }
public async Task NewBotMessage_TenantsAllowedAreEmpty_NoResponse() { // Arrange: Create activity var appInstalledActivity = new Activity { MembersAdded = new List <ChannelAccount> { this.botAccount, }, Type = ActivityTypes.ConversationUpdate, ChannelId = Channels.Msteams, Recipient = this.botAccount, ChannelData = this.teamsChannelData, }; // Tenant filter is active ConfigurationManager.AppSettings[DisableTenantFilterKey] = false.ToString().ToLower(); var sut = new IcebreakerBot(this.dataProvider.Object, this.conversationHelper, MicrosoftAppCredentials.Empty, this.telemetryClient); // Act // Send the message activity to the bot. await this.botAdapter.ProcessActivityAsync(appInstalledActivity, sut.OnTurnAsync, CancellationToken.None); var reply = this.botAdapter.GetNextReply(); // No reply should be received Assert.Null(reply); // Assert UpdateTeamInstallStatusAsync is never called this.dataProvider.Verify( m => m.UpdateTeamInstallStatusAsync(It.IsAny <TeamInstallInfo>(), true), Times.Exactly(0)); }
/// <summary> /// Initializes a new instance of the <see cref="AdminMessageHandler"/> class. /// </summary> /// <param name="bot">The Icebreaker bot instance</param> /// <param name="telemetryClient">The telemetry client instance</param> public AdminMessageHandler(IcebreakerBot bot, TelemetryClient telemetryClient) { this.bot = bot; this.telemetryClient = telemetryClient; this.messageHandlers = new Dictionary <string, Func <string, ConnectorClient, Activity, string, Task> > { { MessageIds.AdminMakePairs, this.HandleAdminMakePairs }, { MessageIds.AdminNotifyPairs, this.HandleAdminNotifyPairs }, { MessageIds.AdminEditTeamSettings, this.HandleAdminEditTeamSettings }, { MessageIds.AdminEditUser, this.HandleAdminEditUser }, { MessageIds.AdminWelcomeTeam, this.HandleWelcomeTeam } }; }
public async Task NewBotMessage_CurrentTenantIsAllowed_ChannelSaved() { // Arrange: Create activity var appInstalledActivity = new Activity { MembersAdded = new List <ChannelAccount> { this.botAccount, }, Type = ActivityTypes.ConversationUpdate, ChannelId = Channels.Msteams, Recipient = this.botAccount, From = this.userAccount, ChannelData = this.teamsChannelData, Conversation = new ConversationAccount(tenantId: Guid.Empty.ToString()), }; // Tenant filter is active ConfigurationManager.AppSettings[DisableTenantFilterKey] = false.ToString().ToLower(); // Only 1 tenant is allowed ConfigurationManager.AppSettings[AllowedTenantsKey] = Guid.Empty.ToString(); var sut = new IcebreakerBot(this.dataProvider.Object, this.conversationHelper, MicrosoftAppCredentials.Empty, this.telemetryClient); // Source tenant is same as allowed tenant in settings this.botAdapter.Conversation.Conversation = appInstalledActivity.Conversation; // Act // Send the message activity to the bot. await this.botAdapter.ProcessActivityAsync(appInstalledActivity, sut.OnTurnAsync, CancellationToken.None); var reply = this.botAdapter.GetNextReply(); // Assert UpdateTeamInstallStatusAsync is called once this.dataProvider.Verify( m => m.UpdateTeamInstallStatusAsync(It.IsAny <TeamInstallInfo>(), true), Times.Exactly(1)); }
public CommonTextRequestHandler(TelemetryClient telemetryClient, IcebreakerBot bot, BotRepository repository) { _telemetryClient = telemetryClient; _bot = bot; _repository = repository; }
public OptInRequestHander(TelemetryClient telemetryClient, IcebreakerBot bot) { _telemetryClient = telemetryClient; _bot = bot; }
/// <summary> /// Initializes a new instance of the <see cref="ProcessNowController"/> class. /// </summary> /// <param name="bot">The Icebreaker bot instance</param> /// <param name="telemetryClient">The telemetry client to use</param> public ProcessNowController(IcebreakerBot bot, TelemetryClient telemetryClient) { this.bot = bot; this.telemetryClient = telemetryClient; }
public FeedbackYesRequestHandler(TelemetryClient telemetryClient, IcebreakerBot bot, BotRepository repository) { _telemetryClient = telemetryClient; _bot = bot; _repository = repository; }
/// <summary> /// Initializes a new instance of the <see cref="ProcessNowController"/> class. /// </summary> /// <param name="bot">The Icebreaker bot instance</param> /// <param name="botCredentials">The bot AAD credentials</param> public ProcessNowController(IcebreakerBot bot, MicrosoftAppCredentials botCredentials) { this.bot = bot; this.botCredentials = botCredentials; }
/// <summary> /// Initializes a new instance of the <see cref="ProcessNowController"/> class. /// </summary> /// <param name="bot">The Icebreaker bot instance</param> /// <param name="botCredentials">The bot AAD credentials</param> public ExportController(IcebreakerBot bot, MicrosoftAppCredentials botCredentials, BotRepository botRepository) { this.bot = bot; this.botCredentials = botCredentials; _botRepository = botRepository; }