public async Task AlertReceiverUnitTest(string flow, string teamTag) { var message = new Message { From = UnitTestBuilder.GetUserNode(), To = UnitTestBuilder.GetBotNode(), Content = PlainText.Parse(flow + teamTag) }; var team = flow.Contains("Remove") ? teamTag : string.Empty; var userContext = new UserContext { AlertTeams = new List <string> { { team } } }; bool success = false; try { success = await flowService.SendAlertFlowAsync(userContext, message, CancellationToken.None); userContext = await contextManager.GetUserContextAsync(message.From, CancellationToken.None); } catch (Exception ex) { ex.ShouldBeNull(); } finally { success.ShouldBeTrue(); if (flow.Contains("Remove")) { userContext.AlertTeams.ShouldNotContain(teamTag); } else if (flow.Contains("Add")) { userContext.AlertTeams.ShouldContain(teamTag); } } }
protected override async Task ReceiveMessageAsync(Message message, Contact contact, UserContext userContext, CancellationToken cancellationToken) { await _flowService.SendAlertFlowAsync(userContext, message, cancellationToken); }