public async Task CreateTicketTaskModuleGetUserInputCard() { var sp = Services.BuildServiceProvider(); var adapter = sp.GetService <TestAdapter>(); adapter.AddUserToken(AuthenticationProvider, adapter.Conversation.ChannelId, adapter.Conversation.User.Id, TestToken, MagicCode); // TaskModule Activity For Fetch var taskFetch = "{\r\n \"data\": {\r\n \"data\": {\r\n \"TaskModuleFlowType\": \"CreateTicket_Form\",\r\n \"Submit\": false\r\n },\r\n \"type\": \"task / fetch\"\r\n },\r\n \"context\": {\r\n \"theme\": \"dark\"\r\n }\r\n}"; var activity = new Activity { Type = ActivityTypes.Invoke, Name = "task/fetch", Value = JObject.Parse(taskFetch) }; var turnContext = new TurnContext(adapter, activity); var teamsImplementation = new CreateTicketTeamsImplementation(sp); TaskModuleContinueResponse response = await teamsImplementation.OnTeamsTaskModuleFetchAsync(turnContext, CancellationToken.None); Assert.IsNotNull(response); Assert.AreEqual("Create Incident", response.Value.Title); var attachment = response.Value.Card; Assert.IsNotNull(attachment); var adaptiveCard = (AdaptiveCard)attachment.Content; Assert.IsNotNull(adaptiveCard); Assert.AreEqual(adaptiveCard.Id, "GetUserInput"); // TODO: Add more validation steps on AdaptiveCard }
public async Task CreateTicketTaskModuleSubmitUserResponse() { var sp = Services.BuildServiceProvider(); var adapter = sp.GetService <TestAdapter>(); var conversationState = sp.GetService <ConversationState>(); var stateAccessor = conversationState.CreateProperty <SkillState>(nameof(SkillState)); var skillState = new SkillState(); skillState.AccessTokenResponse = new TokenResponse { Token = "Test" }; // TaskModule Activity For Submit var taskSubmit = "{\r\n \"data\": {\r\n \"msteams\": {\r\n \"type\": \"task/fetch\"\r\n },\r\n \"data\": {\r\n \"TaskModuleFlowType\": \"CreateTicket_Form\",\r\n \"Submit\": true\r\n },\r\n \"IncidentTitle\": \"Test15\",\r\n \"IncidentDescription\": \"Test15\",\r\n \"IncidentUrgency\": \"Medium\"\r\n },\r\n \"context\": {\r\n \"theme\": \"dark\"\r\n }\r\n}"; var activity = new Activity { ChannelId = "test", Conversation = new ConversationAccount { Id = "Test" }, Type = ActivityTypes.Invoke, Name = "task/fetch", Value = JObject.Parse(taskSubmit) }; var turnContext = new TurnContext(adapter, activity); await stateAccessor.SetAsync(turnContext, skillState, CancellationToken.None); var teamsImplementation = new CreateTicketTeamsImplementation(sp); var response = await teamsImplementation.OnTeamsTaskModuleSubmitAsync(turnContext, CancellationToken.None); Assert.IsNotNull(response); Assert.AreEqual("Incident Created", response.Value.Title); var attachment = response.Value.Card; Assert.IsNotNull(attachment); var adaptiveCard = (AdaptiveCard)attachment.Content; Assert.IsNotNull(adaptiveCard); Assert.AreEqual(adaptiveCard.Id, "IncidentResponseCard"); // TODO: Add more validation steps on AdaptiveCard }