public void TestSkillConversationEncoding() { var conversationId = Guid.NewGuid().ToString("N"); var serviceUrl = "http://test.com/xyz?id=1&id=2"; var sc = new TestConversationIdFactory(); var skillConversationId = sc.CreateSkillConversationId(conversationId, serviceUrl); var(returnedConversationId, returnedServerUrl) = sc.GetConversationInfo(skillConversationId); Assert.Equal(conversationId, returnedConversationId); Assert.Equal(serviceUrl, returnedServerUrl); }
public async Task TestSkillAdapterApiCalls() { var activityId = Guid.NewGuid().ToString("N"); var botId = Guid.NewGuid().ToString("N"); var botAdapter = CreateAdapter("TestSkillAdapterApiCalls"); var skillAccount = ObjectPath.Clone(botAdapter.Conversation.Bot); var skillId = "testSkill"; skillAccount.Properties["SkillId"] = skillId; var middleware = new AssertInvokeMiddleware(botAdapter, activityId); botAdapter.Use(middleware); var bot = new CallbackBot(); var skillClient = new SkillHandlerInstanceForTests(botAdapter, bot, new Mock <ICredentialProvider>().Object, new AuthenticationConfiguration()); var sc = new TestConversationIdFactory(); var skillConversationId = sc.CreateSkillConversationId(botAdapter.Conversation.Conversation.Id, botAdapter.Conversation.ServiceUrl); var claimsIdentity = new ClaimsIdentity(); claimsIdentity.AddClaim(new Claim(AuthenticationConstants.AudienceClaim, botId)); claimsIdentity.AddClaim(new Claim(AuthenticationConstants.AppIdClaim, botId)); claimsIdentity.AddClaim(new Claim(AuthenticationConstants.ServiceUrlClaim, botAdapter.Conversation.ServiceUrl)); object result = await skillClient.TestOnCreateConversationAsync(claimsIdentity, new ConversationParameters()); Assert.IsType <ConversationResourceResponse>(result); //Assert.Equal(middleware.NewResourceId, ((ConversationResourceResponse)result).Id); await skillClient.TestOnDeleteActivityAsync(claimsIdentity, skillConversationId, activityId); await skillClient.TestOnDeleteConversationMemberAsync(claimsIdentity, skillConversationId, "user2"); result = await skillClient.TestOnGetActivityMembersAsync(claimsIdentity, skillConversationId, activityId); Assert.IsAssignableFrom <IList <ChannelAccount> >(result); result = await skillClient.TestOnGetConversationMembersAsync(claimsIdentity, skillConversationId); Assert.IsAssignableFrom <IList <ChannelAccount> >(result); result = await skillClient.TestOnGetConversationPagedMembersAsync(claimsIdentity, skillConversationId); Assert.IsType <PagedMembersResult>(result); result = await skillClient.TestOnGetConversationPagedMembersAsync(claimsIdentity, skillConversationId, 10); Assert.IsType <PagedMembersResult>(result); var pagedMembersResult = (PagedMembersResult)result; result = await skillClient.TestOnGetConversationPagedMembersAsync(claimsIdentity, skillConversationId, continuationToken : pagedMembersResult.ContinuationToken); Assert.IsType <PagedMembersResult>(result); result = await skillClient.TestOnGetConversationsAsync(claimsIdentity, skillConversationId); Assert.IsType <ConversationsResult>(result); var conversationsResult = (ConversationsResult)result; result = await skillClient.TestOnGetConversationsAsync(claimsIdentity, skillConversationId, continuationToken : conversationsResult.ContinuationToken); Assert.IsType <ConversationsResult>(result); var msgActivity = Activity.CreateMessageActivity(); msgActivity.Conversation = botAdapter.Conversation.Conversation; msgActivity.Text = "yo"; result = await skillClient.TestOnSendToConversationAsync(claimsIdentity, skillConversationId, (Activity)msgActivity); Assert.IsType <ResourceResponse>(result); Assert.Equal(middleware.NewResourceId, ((ResourceResponse)result).Id); msgActivity.Id = ((ResourceResponse)result).Id; result = await skillClient.TestOnReplyToActivityAsync(claimsIdentity, skillConversationId, activityId, (Activity)msgActivity); Assert.IsType <ResourceResponse>(result); Assert.Equal(middleware.NewResourceId, ((ResourceResponse)result).Id); msgActivity.Id = ((ResourceResponse)result).Id; result = await skillClient.TestOnSendConversationHistoryAsync(claimsIdentity, skillConversationId, new Transcript()); Assert.IsType <ResourceResponse>(result); Assert.Equal(middleware.NewResourceId, ((ResourceResponse)result).Id); result = await skillClient.TestOnUpdateActivityAsync(claimsIdentity, skillConversationId, activityId, (Activity)msgActivity); Assert.IsType <ResourceResponse>(result); Assert.Equal(middleware.NewResourceId, ((ResourceResponse)result).Id); result = await skillClient.TestOnUploadAttachmentAsync(claimsIdentity, skillConversationId, new AttachmentData()); Assert.IsType <ResourceResponse>(result); Assert.Equal(middleware.NewResourceId, ((ResourceResponse)result).Id); }