microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
core/test/Microsoft.Teams.Bot.Apps.UnitTests/InvokeActivityTest.cs
51lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using System; |
| 5 | using System.Collections.Generic; |
| 6 | using System.ComponentModel; |
| 7 | using System.Linq; |
| 8 | using System.Text; |
| 9 | using System.Text.Json.Nodes; |
| 10 | using System.Threading.Tasks; |
| 11 | using Microsoft.Teams.Bot.Apps.Schema; |
| 12 | using Microsoft.Teams.Bot.Apps.Schema.MessageActivities; |
| 13 | using Microsoft.Teams.Bot.Core.Schema; |
| 14 | |
| 15 | namespace Microsoft.Teams.Bot.Apps.UnitTests; |
| 16 | |
| 17 | public 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 | |