public void TestSkillConversationEmptyCtor() { Assert.Throws <NullReferenceException>(() => { var sc = new SkillConversation(string.Empty); var cid = sc.GetSkillConversationId(); }); }
public void TestSkillConversationNullCtor() { Assert.Throws <ArgumentNullException>(() => { var sc = new SkillConversation(null); var cid = sc.GetSkillConversationId(); }); }
public void TestSkillConversationBogusPayload() { Assert.Throws <IndexOutOfRangeException>(() => { var test = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new object[0]))); var sc = new SkillConversation(test); var cid = sc.GetSkillConversationId(); }); }
public void TestSkillConversationEmptyCtor() { try { var sc = new SkillConversation(string.Empty); var cid = sc.GetSkillConversationId(); Assert.Fail("Should have thrown on empty"); } catch (Exception) { } }
public void TestSkillConversationNullCtor() { try { var sc = new SkillConversation(null); var cid = sc.GetSkillConversationId(); Assert.Fail("Should have thrown on null"); } catch (Exception) { } }
public void TestSkillConversationNullUrl() { Assert.Throws <ArgumentNullException>(() => { var sc = new SkillConversation() { ConversationId = Guid.NewGuid().ToString("N"), ServiceUrl = null }; var cid = sc.GetSkillConversationId(); }); }
public void TestSkillConversationTestNullId() { Assert.Throws <ArgumentNullException>(() => { var sc = new SkillConversation() { ConversationId = null, ServiceUrl = "http://test.com/xyz?id=1&id=2" }; var cid = sc.GetSkillConversationId(); }); }
public void TestSkillConversationBogusPayload() { try { var test = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new object[0]))); var sc = new SkillConversation(test); var cid = sc.GetSkillConversationId(); Assert.Fail("Should have thrown on bogusity"); } catch (Exception) { } }
public void TestSkillConversationEncoding() { var sc = new SkillConversation { ConversationId = Guid.NewGuid().ToString("N"), ServiceUrl = "http://test.com/xyz?id=1&id=2" }; var skillConversationId = sc.GetSkillConversationId(); var sc2 = new SkillConversation(skillConversationId); Assert.AreEqual(sc.ConversationId, sc2.ConversationId); Assert.AreEqual(sc.ServiceUrl, sc2.ServiceUrl); }
public void TestSkillConversationNullUrl() { try { var sc = new SkillConversation { ConversationId = Guid.NewGuid().ToString("N"), ServiceUrl = null }; var cid = sc.GetSkillConversationId(); Assert.Fail("Should have thrown on null"); } catch (Exception) { } }
public void TestSkillConversationTestNullId() { try { var sc = new SkillConversation { ConversationId = null, ServiceUrl = "http://test.com/xyz?id=1&id=2" }; var cid = sc.GetSkillConversationId(); Assert.Fail("Should have thrown on null"); } catch (Exception) { } }
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 skillAdapter = new BotFrameworkSkillHostAdapter(botAdapter, new MicrosoftAppCredentials(string.Empty, string.Empty), new AuthenticationConfiguration(), configuration: new ConfigurationBuilder().Build()); var sc = new SkillConversation() { ServiceUrl = botAdapter.Conversation.ServiceUrl, ConversationId = botAdapter.Conversation.Conversation.Id }; var skillConversationId = sc.GetSkillConversationId(); 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 skillAdapter.CreateConversationAsync(bot, claimsIdentity, skillConversationId, new ConversationParameters()); Assert.IsType <ConversationResourceResponse>(result); Assert.Equal(middleware.NewResourceId, ((ConversationResourceResponse)result).Id); await skillAdapter.DeleteActivityAsync(bot, claimsIdentity, skillConversationId, activityId); await skillAdapter.DeleteConversationMemberAsync(bot, claimsIdentity, skillConversationId, "user2"); result = await skillAdapter.GetActivityMembersAsync(bot, claimsIdentity, skillConversationId, activityId); Assert.IsAssignableFrom <IList <ChannelAccount> >(result); result = await skillAdapter.GetConversationMembersAsync(bot, claimsIdentity, skillConversationId); Assert.IsAssignableFrom <IList <ChannelAccount> >(result); result = await skillAdapter.GetConversationPagedMembersAsync(bot, claimsIdentity, skillConversationId); Assert.IsType <PagedMembersResult>(result); result = await skillAdapter.GetConversationPagedMembersAsync(bot, claimsIdentity, skillConversationId, 10); Assert.IsType <PagedMembersResult>(result); var pagedMembersResult = (PagedMembersResult)result; result = await skillAdapter.GetConversationPagedMembersAsync(bot, claimsIdentity, skillConversationId, continuationToken : pagedMembersResult.ContinuationToken); Assert.IsType <PagedMembersResult>(result); result = await skillAdapter.GetConversationsAsync(bot, claimsIdentity, skillConversationId); Assert.IsType <ConversationsResult>(result); var conversationsResult = (ConversationsResult)result; result = await skillAdapter.GetConversationsAsync(bot, claimsIdentity, skillConversationId, continuationToken : conversationsResult.ContinuationToken); Assert.IsType <ConversationsResult>(result); var msgActivity = Activity.CreateMessageActivity(); msgActivity.Conversation = botAdapter.Conversation.Conversation; msgActivity.From = skillAccount; msgActivity.Recipient = botAdapter.Conversation.User; msgActivity.Text = "yo"; result = await skillAdapter.SendToConversationAsync(bot, claimsIdentity, skillConversationId, (Activity)msgActivity); Assert.IsType <ResourceResponse>(result); Assert.Equal(middleware.NewResourceId, ((ResourceResponse)result).Id); msgActivity.Id = ((ResourceResponse)result).Id; result = await skillAdapter.ReplyToActivityAsync(bot, claimsIdentity, skillConversationId, activityId, (Activity)msgActivity); Assert.IsType <ResourceResponse>(result); Assert.Equal(middleware.NewResourceId, ((ResourceResponse)result).Id); result = await skillAdapter.SendConversationHistoryAsync(bot, claimsIdentity, skillConversationId, new Transcript()); Assert.IsType <ResourceResponse>(result); Assert.Equal(middleware.NewResourceId, ((ResourceResponse)result).Id); result = await skillAdapter.UpdateActivityAsync(bot, claimsIdentity, skillConversationId, activityId, (Activity)msgActivity); Assert.IsType <ResourceResponse>(result); Assert.Equal(middleware.NewResourceId, ((ResourceResponse)result).Id); result = await skillAdapter.UploadAttachmentAsync(bot, claimsIdentity, skillConversationId, new AttachmentData()); Assert.IsType <ResourceResponse>(result); Assert.Equal(middleware.NewResourceId, ((ResourceResponse)result).Id); }