microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/sub-pr-338

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

core/test/Microsoft.Teams.Bot.Apps.UnitTests/InvokeActivityTest.cs

51lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4using System;
5using System.Collections.Generic;
6using System.ComponentModel;
7using System.Linq;
8using System.Text;
9using System.Text.Json.Nodes;
10using System.Threading.Tasks;
11using Microsoft.Teams.Bot.Apps.Schema;
12using Microsoft.Teams.Bot.Apps.Schema.MessageActivities;
13using Microsoft.Teams.Bot.Core.Schema;
14
15namespace Microsoft.Teams.Bot.Apps.UnitTests;
16
17public class InvokeActivityTest
18{
19 [Fact]
20 public void DefaultCtor()
21 {
22 var ia = new InvokeActivity();
23 Assert.NotNull(ia);
24 Assert.Equal(TeamsActivityType.Invoke, ia.Type);
25 Assert.Null(ia.Name);
26 Assert.Null(ia.Value);
27 // Assert.Null(ia.Conversation);
28 }
29
30 [Fact]
31 public void FromCoreActivityWithValue()
32 {
33 var coreActivity = new CoreActivity
34 {
35 Type = TeamsActivityType.Invoke,
36 Value = JsonNode.Parse("{ \"key\": \"value\" }"),
37 Conversation = new Conversation { Id = "convId" },
38 Properties = new ExtendedPropertiesDictionary
39 {
40 { "name", "testName" }
41 }
42 };
43 var ia = InvokeActivity.FromActivity(coreActivity);
44 Assert.NotNull(ia);
45 Assert.Equal(TeamsActivityType.Invoke, ia.Type);
46 Assert.Equal("testName", ia.Name);
47 Assert.NotNull(ia.Value);
48 Assert.Equal("convId", ia.Conversation?.Id);
49 Assert.Equal("value", ia.Value?["key"]?.ToString());
50 }
51}
52