microsoft/teams.net

Public

mirrored from https://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v2.0.8

Branches

Tags

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

Clone

HTTPS

Download ZIP

core/test/Microsoft.Teams.Core.UnitTests/Schema/ConversationTests.cs

86lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4using Microsoft.Teams.Core.Schema;
5
6namespace Microsoft.Teams.Core.UnitTests.Schema;
7
8public class ConversationTests
9{
10 [Fact]
11 public void ToThreadedConversationId_ConstructsThreadedConversationId()
12 {
13 var result = ConversationExtensions.ToThreadedConversationId("19:abc@thread.skype", "1680000000000");
14 Assert.Equal("19:abc@thread.skype;messageid=1680000000000", result);
15 }
16
17 [Fact]
18 public void ToThreadedConversationId_WorksWithDifferentConversationIdFormats()
19 {
20 var result = ConversationExtensions.ToThreadedConversationId("19:meeting_abc@thread.v2", "999");
21 Assert.Equal("19:meeting_abc@thread.v2;messageid=999", result);
22 }
23
24 [Fact]
25 public void ToThreadedConversationId_ThrowsOnEmptyConversationId()
26 {
27 Assert.Throws<ArgumentException>(() => ConversationExtensions.ToThreadedConversationId("", "123"));
28 }
29
30 [Fact]
31 public void ToThreadedConversationId_ThrowsOnNullConversationId()
32 {
33 Assert.Throws<ArgumentException>(() => ConversationExtensions.ToThreadedConversationId(null!, "123"));
34 }
35
36 [Fact]
37 public void ToThreadedConversationId_ThrowsOnEmptyMessageId()
38 {
39 Assert.Throws<ArgumentException>(() => ConversationExtensions.ToThreadedConversationId("19:abc@thread.skype", ""));
40 }
41
42 [Fact]
43 public void ToThreadedConversationId_ThrowsOnZeroMessageId()
44 {
45 Assert.Throws<ArgumentException>(() => ConversationExtensions.ToThreadedConversationId("19:abc@thread.skype", "0"));
46 }
47
48 [Fact]
49 public void ToThreadedConversationId_ThrowsOnNonNumericMessageId()
50 {
51 Assert.Throws<ArgumentException>(() => ConversationExtensions.ToThreadedConversationId("19:abc@thread.skype", "abc"));
52 }
53
54 [Fact]
55 public void ToThreadedConversationId_ThrowsOnNegativeMessageId()
56 {
57 Assert.Throws<ArgumentException>(() => ConversationExtensions.ToThreadedConversationId("19:abc@thread.skype", "-1"));
58 }
59
60 [Fact]
61 public void ToThreadedConversationId_ThrowsOnDecimalMessageId()
62 {
63 Assert.Throws<ArgumentException>(() => ConversationExtensions.ToThreadedConversationId("19:abc@thread.skype", "1.5"));
64 }
65
66 [Fact]
67 public void ToThreadedConversationId_StripsExistingMessageIdAndReplacesWithThreadRoot()
68 {
69 var result = ConversationExtensions.ToThreadedConversationId("19:abc@thread.skype;messageid=111", "222");
70 Assert.Equal("19:abc@thread.skype;messageid=222", result);
71 }
72
73 [Fact]
74 public void ThreadId_StripsMessageIdSuffix()
75 {
76 var conv = new Conversation("19:abc@thread.skype;messageid=1680000000000");
77 Assert.Equal("19:abc@thread.skype", conv.ThreadId());
78 }
79
80 [Fact]
81 public void ThreadId_ReturnsIdWhenNoSuffix()
82 {
83 var conv = new Conversation("19:abc@thread.skype");
84 Assert.Equal("19:abc@thread.skype", conv.ThreadId());
85 }
86}