microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
core/test/Microsoft.Teams.Bot.Apps.UnitTests/InvokeActivityTest.cs
45lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using System.Text.Json.Nodes; |
| 5 | using Microsoft.Teams.Bot.Apps.Handlers; |
| 6 | using Microsoft.Teams.Bot.Apps.Schema; |
| 7 | using Microsoft.Teams.Bot.Core.Schema; |
| 8 | |
| 9 | namespace Microsoft.Teams.Bot.Apps.UnitTests; |
| 10 | |
| 11 | public class InvokeActivityTest |
| 12 | { |
| 13 | [Fact] |
| 14 | public void DefaultCtor() |
| 15 | { |
| 16 | InvokeActivity ia = new(); |
| 17 | Assert.NotNull(ia); |
| 18 | Assert.Equal(TeamsActivityType.Invoke, ia.Type); |
| 19 | Assert.Null(ia.Name); |
| 20 | Assert.Null(ia.Value); |
| 21 | // Assert.Null(ia.Conversation); |
| 22 | } |
| 23 | |
| 24 | [Fact] |
| 25 | public void FromCoreActivityWithValue() |
| 26 | { |
| 27 | CoreActivity coreActivity = new() |
| 28 | { |
| 29 | Type = TeamsActivityType.Invoke, |
| 30 | Value = JsonNode.Parse("{ \"key\": \"value\" }"), |
| 31 | Conversation = new Conversation { Id = "convId" }, |
| 32 | Properties = new ExtendedPropertiesDictionary |
| 33 | { |
| 34 | { "name", "testName" } |
| 35 | } |
| 36 | }; |
| 37 | InvokeActivity ia = InvokeActivity.FromActivity(coreActivity); |
| 38 | Assert.NotNull(ia); |
| 39 | Assert.Equal(TeamsActivityType.Invoke, ia.Type); |
| 40 | Assert.Equal("testName", ia.Name); |
| 41 | Assert.NotNull(ia.Value); |
| 42 | Assert.Equal("convId", ia.Conversation?.Id); |
| 43 | Assert.Equal("value", ia.Value?["key"]?.ToString()); |
| 44 | } |
| 45 | } |
| 46 | |