microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
core/test/Microsoft.Teams.Bot.Core.Tests/TeamsApiClientTests.cs
597lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Teams.Bot.Core; |
| 5 | using Microsoft.Teams.Bot.Core.Hosting; |
| 6 | using Microsoft.Teams.Bot.Core.Schema; |
| 7 | using Microsoft.Extensions.Configuration; |
| 8 | using Microsoft.Extensions.DependencyInjection; |
| 9 | using Microsoft.Extensions.Logging; |
| 10 | using Microsoft.Teams.Bot.Apps; |
| 11 | using Xunit.Abstractions; |
| 12 | |
| 13 | namespace Microsoft.Bot.Core.Tests; |
| 14 | |
| 15 | public class TeamsApiClientTests |
| 16 | { |
| 17 | private readonly ServiceProvider _serviceProvider; |
| 18 | private readonly TeamsApiClient _teamsClient; |
| 19 | private readonly Uri _serviceUrl; |
| 20 | private readonly ConversationAccount _recipient = new ConversationAccount(); |
| 21 | private AgenticIdentity? _agenticIdentity; |
| 22 | |
| 23 | public TeamsApiClientTests(ITestOutputHelper outputHelper) |
| 24 | { |
| 25 | IConfigurationBuilder builder = new ConfigurationBuilder() |
| 26 | .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) |
| 27 | .AddEnvironmentVariables(); |
| 28 | |
| 29 | IConfiguration configuration = builder.Build(); |
| 30 | |
| 31 | ServiceCollection services = new(); |
| 32 | services.AddLogging((builder) => { |
| 33 | builder.AddXUnit(outputHelper); |
| 34 | builder.AddFilter("System.Net", LogLevel.Warning); |
| 35 | builder.AddFilter("Microsoft.Identity", LogLevel.Error); |
| 36 | builder.AddFilter("Microsoft.Teams", LogLevel.Information); |
| 37 | }); |
| 38 | services.AddSingleton(configuration); |
| 39 | services.AddTeamsBotApplication(); |
| 40 | _serviceProvider = services.BuildServiceProvider(); |
| 41 | _teamsClient = _serviceProvider.GetRequiredService<TeamsApiClient>(); |
| 42 | _serviceUrl = new Uri(Environment.GetEnvironmentVariable("TEST_SERVICEURL") ?? "https://smba.trafficmanager.net/teams/"); |
| 43 | |
| 44 | string agenticAppBlueprintId = Environment.GetEnvironmentVariable("AzureAd__ClientId") ?? throw new InvalidOperationException("AzureAd__ClientId environment variable not set"); |
| 45 | string? agenticAppId = Environment.GetEnvironmentVariable("TEST_AGENTIC_APPID");// ?? throw new InvalidOperationException("TEST_AGENTIC_APPID environment variable not set"); |
| 46 | string? agenticUserId = Environment.GetEnvironmentVariable("TEST_AGENTIC_USERID");// ?? throw new InvalidOperationException("TEST_AGENTIC_USERID environment variable not set"); |
| 47 | |
| 48 | _agenticIdentity = null; |
| 49 | if (!string.IsNullOrEmpty(agenticAppId) && !string.IsNullOrEmpty(agenticUserId)) |
| 50 | { |
| 51 | _recipient.Properties.Add("agenticAppBlueprintId", agenticAppBlueprintId); |
| 52 | _recipient.Properties.Add("agenticAppId", agenticAppId); |
| 53 | _recipient.Properties.Add("agenticUserId", agenticUserId); |
| 54 | _agenticIdentity = AgenticIdentity.FromProperties(_recipient.Properties); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | #region Team Operations Tests |
| 59 | |
| 60 | [Fact] |
| 61 | public async Task FetchChannelList() |
| 62 | { |
| 63 | string teamId = Environment.GetEnvironmentVariable("TEST_TEAMID") ?? throw new InvalidOperationException("TEST_TEAMID environment variable not set"); |
| 64 | |
| 65 | ChannelList result = await _teamsClient.FetchChannelListAsync( |
| 66 | teamId, |
| 67 | _serviceUrl, |
| 68 | _agenticIdentity, |
| 69 | cancellationToken: CancellationToken.None); |
| 70 | |
| 71 | Assert.NotNull(result); |
| 72 | Assert.NotNull(result.Channels); |
| 73 | Assert.NotEmpty(result.Channels); |
| 74 | |
| 75 | Console.WriteLine($"Found {result.Channels.Count} channels in team {teamId}:"); |
| 76 | foreach (var channel in result.Channels) |
| 77 | { |
| 78 | Console.WriteLine($" - Id: {channel.Id}, Name: {channel.Name}"); |
| 79 | Assert.NotNull(channel); |
| 80 | Assert.NotNull(channel.Id); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | [Fact] |
| 85 | public async Task FetchChannelList_FailsWithInvalidTeamId() |
| 86 | { |
| 87 | await Assert.ThrowsAsync<HttpRequestException>(() |
| 88 | => _teamsClient.FetchChannelListAsync("invalid-team-id", _serviceUrl, _agenticIdentity)); |
| 89 | } |
| 90 | |
| 91 | [Fact] |
| 92 | public async Task FetchTeamDetails() |
| 93 | { |
| 94 | string teamId = Environment.GetEnvironmentVariable("TEST_TEAMID") ?? throw new InvalidOperationException("TEST_TEAMID environment variable not set"); |
| 95 | |
| 96 | TeamDetails result = await _teamsClient.FetchTeamDetailsAsync( |
| 97 | teamId, |
| 98 | _serviceUrl, |
| 99 | _agenticIdentity, |
| 100 | cancellationToken: CancellationToken.None); |
| 101 | |
| 102 | Assert.NotNull(result); |
| 103 | Assert.NotNull(result.Id); |
| 104 | |
| 105 | Console.WriteLine($"Team details for {teamId}:"); |
| 106 | Console.WriteLine($" - Id: {result.Id}"); |
| 107 | Console.WriteLine($" - Name: {result.Name}"); |
| 108 | Console.WriteLine($" - AAD Group Id: {result.AadGroupId}"); |
| 109 | Console.WriteLine($" - Channel Count: {result.ChannelCount}"); |
| 110 | Console.WriteLine($" - Member Count: {result.MemberCount}"); |
| 111 | Console.WriteLine($" - Type: {result.Type}"); |
| 112 | } |
| 113 | |
| 114 | [Fact] |
| 115 | public async Task FetchTeamDetails_FailsWithInvalidTeamId() |
| 116 | { |
| 117 | await Assert.ThrowsAsync<HttpRequestException>(() |
| 118 | => _teamsClient.FetchTeamDetailsAsync("invalid-team-id", _serviceUrl, _agenticIdentity)); |
| 119 | } |
| 120 | |
| 121 | #endregion |
| 122 | |
| 123 | #region Meeting Operations Tests |
| 124 | |
| 125 | [Fact(Skip = "FetchMeetingInfo requires permissions")] |
| 126 | public async Task FetchMeetingInfo() |
| 127 | { |
| 128 | string meetingId = Environment.GetEnvironmentVariable("TEST_MEETINGID") ?? throw new InvalidOperationException("TEST_MEETINGID environment variable not set"); |
| 129 | |
| 130 | MeetingInfo result = await _teamsClient.FetchMeetingInfoAsync( |
| 131 | meetingId, |
| 132 | _serviceUrl, |
| 133 | _agenticIdentity, |
| 134 | cancellationToken: CancellationToken.None); |
| 135 | |
| 136 | Assert.NotNull(result); |
| 137 | //Assert.NotNull(result.Id); |
| 138 | |
| 139 | Console.WriteLine($"Meeting info for {meetingId}:"); |
| 140 | |
| 141 | if (result.Details != null) |
| 142 | { |
| 143 | Console.WriteLine($" - Title: {result.Details.Title}"); |
| 144 | Console.WriteLine($" - Type: {result.Details.Type}"); |
| 145 | Console.WriteLine($" - Join URL: {result.Details.JoinUrl}"); |
| 146 | Console.WriteLine($" - Scheduled Start: {result.Details.ScheduledStartTime}"); |
| 147 | Console.WriteLine($" - Scheduled End: {result.Details.ScheduledEndTime}"); |
| 148 | } |
| 149 | if (result.Organizer != null) |
| 150 | { |
| 151 | Console.WriteLine($" - Organizer: {result.Organizer.Name} ({result.Organizer.Id})"); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | [Fact] |
| 156 | public async Task FetchMeetingInfo_FailsWithInvalidMeetingId() |
| 157 | { |
| 158 | await Assert.ThrowsAsync<HttpRequestException>(() |
| 159 | => _teamsClient.FetchMeetingInfoAsync("invalid-meeting-id", _serviceUrl, _agenticIdentity)); |
| 160 | } |
| 161 | |
| 162 | [Fact] |
| 163 | public async Task FetchParticipant() |
| 164 | { |
| 165 | string meetingId = Environment.GetEnvironmentVariable("TEST_MEETINGID") ?? throw new InvalidOperationException("TEST_MEETINGID environment variable not set"); |
| 166 | string participantId = Environment.GetEnvironmentVariable("TEST_USER_ID") ?? throw new InvalidOperationException("TEST_USER_ID environment variable not set"); |
| 167 | string tenantId = Environment.GetEnvironmentVariable("TEST_TENANTID") ?? throw new InvalidOperationException("TEST_TENANTID environment variable not set"); |
| 168 | |
| 169 | MeetingParticipant result = await _teamsClient.FetchParticipantAsync( |
| 170 | meetingId, |
| 171 | participantId, |
| 172 | tenantId, |
| 173 | _serviceUrl, |
| 174 | _agenticIdentity, |
| 175 | cancellationToken: CancellationToken.None); |
| 176 | |
| 177 | Assert.NotNull(result); |
| 178 | |
| 179 | Console.WriteLine($"Participant info for {participantId} in meeting {meetingId}:"); |
| 180 | if (result.User != null) |
| 181 | { |
| 182 | Console.WriteLine($" - User Id: {result.User.Id}"); |
| 183 | Console.WriteLine($" - User Name: {result.User.Name}"); |
| 184 | } |
| 185 | if (result.Meeting != null) |
| 186 | { |
| 187 | Console.WriteLine($" - Role: {result.Meeting.Role}"); |
| 188 | Console.WriteLine($" - In Meeting: {result.Meeting.InMeeting}"); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | [Fact(Skip = "Requires active meeting context")] |
| 193 | public async Task SendMeetingNotification() |
| 194 | { |
| 195 | string meetingId = Environment.GetEnvironmentVariable("TEST_MEETINGID") ?? throw new InvalidOperationException("TEST_MEETINGID environment variable not set"); |
| 196 | string participantId = Environment.GetEnvironmentVariable("TEST_USER_ID") ?? throw new InvalidOperationException("TEST_USER_ID environment variable not set"); |
| 197 | |
| 198 | var notification = new TargetedMeetingNotification |
| 199 | { |
| 200 | Value = new TargetedMeetingNotificationValue |
| 201 | { |
| 202 | Recipients = [participantId], |
| 203 | Surfaces = |
| 204 | [ |
| 205 | new MeetingNotificationSurface |
| 206 | { |
| 207 | Surface = "meetingStage", |
| 208 | ContentType = "task", |
| 209 | Content = new { title = "Test Notification", url = "https://example.com" } |
| 210 | } |
| 211 | ] |
| 212 | } |
| 213 | }; |
| 214 | |
| 215 | MeetingNotificationResponse result = await _teamsClient.SendMeetingNotificationAsync( |
| 216 | meetingId, |
| 217 | notification, |
| 218 | _serviceUrl, |
| 219 | _agenticIdentity, |
| 220 | cancellationToken: CancellationToken.None); |
| 221 | |
| 222 | Assert.NotNull(result); |
| 223 | |
| 224 | Console.WriteLine($"Meeting notification sent to meeting {meetingId}"); |
| 225 | if (result.RecipientsFailureInfo != null && result.RecipientsFailureInfo.Count > 0) |
| 226 | { |
| 227 | Console.WriteLine($"Failed recipients:"); |
| 228 | foreach (var failure in result.RecipientsFailureInfo) |
| 229 | { |
| 230 | Console.WriteLine($" - {failure.RecipientMri}: {failure.ErrorCode} - {failure.FailureReason}"); |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | #endregion |
| 236 | |
| 237 | #region Batch Message Operations Tests |
| 238 | |
| 239 | [Fact(Skip = "Batch operations require special permissions")] |
| 240 | public async Task SendMessageToListOfUsers() |
| 241 | { |
| 242 | string tenantId = Environment.GetEnvironmentVariable("TENANT_ID") ?? throw new InvalidOperationException("TENANT_ID environment variable not set"); |
| 243 | string userId = Environment.GetEnvironmentVariable("TEST_USER_ID") ?? throw new InvalidOperationException("TEST_USER_ID environment variable not set"); |
| 244 | |
| 245 | CoreActivity activity = new() |
| 246 | { |
| 247 | Type = ActivityType.Message, |
| 248 | Properties = { { "text", $"Batch message from Automated tests at `{DateTime.UtcNow:s}`" } } |
| 249 | }; |
| 250 | |
| 251 | IList<TeamMember> members = |
| 252 | [ |
| 253 | new TeamMember(userId) |
| 254 | ]; |
| 255 | |
| 256 | string operationId = await _teamsClient.SendMessageToListOfUsersAsync( |
| 257 | activity, |
| 258 | members, |
| 259 | tenantId, |
| 260 | _serviceUrl, |
| 261 | _agenticIdentity, |
| 262 | cancellationToken: CancellationToken.None); |
| 263 | |
| 264 | Assert.NotNull(operationId); |
| 265 | Assert.NotEmpty(operationId); |
| 266 | |
| 267 | Console.WriteLine($"Batch message sent. Operation ID: {operationId}"); |
| 268 | } |
| 269 | |
| 270 | [Fact(Skip = "Batch operations require special permissions")] |
| 271 | public async Task SendMessageToAllUsersInTenant() |
| 272 | { |
| 273 | string tenantId = Environment.GetEnvironmentVariable("TENANT_ID") ?? throw new InvalidOperationException("TENANT_ID environment variable not set"); |
| 274 | |
| 275 | CoreActivity activity = new() |
| 276 | { |
| 277 | Type = ActivityType.Message, |
| 278 | Properties = { { "text", $"Tenant-wide message from Automated tests at `{DateTime.UtcNow:s}`" } } |
| 279 | }; |
| 280 | |
| 281 | string operationId = await _teamsClient.SendMessageToAllUsersInTenantAsync( |
| 282 | activity, |
| 283 | tenantId, |
| 284 | _serviceUrl, |
| 285 | _agenticIdentity, |
| 286 | cancellationToken: CancellationToken.None); |
| 287 | |
| 288 | Assert.NotNull(operationId); |
| 289 | Assert.NotEmpty(operationId); |
| 290 | |
| 291 | Console.WriteLine($"Tenant-wide message sent. Operation ID: {operationId}"); |
| 292 | } |
| 293 | |
| 294 | [Fact(Skip = "Batch operations require special permissions")] |
| 295 | public async Task SendMessageToAllUsersInTeam() |
| 296 | { |
| 297 | string tenantId = Environment.GetEnvironmentVariable("TENANT_ID") ?? throw new InvalidOperationException("TENANT_ID environment variable not set"); |
| 298 | string teamId = Environment.GetEnvironmentVariable("TEST_TEAMID") ?? throw new InvalidOperationException("TEST_TEAMID environment variable not set"); |
| 299 | |
| 300 | CoreActivity activity = new() |
| 301 | { |
| 302 | Type = ActivityType.Message, |
| 303 | Properties = { { "text", $"Team-wide message from Automated tests at `{DateTime.UtcNow:s}`" } } |
| 304 | }; |
| 305 | |
| 306 | string operationId = await _teamsClient.SendMessageToAllUsersInTeamAsync( |
| 307 | activity, |
| 308 | teamId, |
| 309 | tenantId, |
| 310 | _serviceUrl, |
| 311 | _agenticIdentity, |
| 312 | cancellationToken: CancellationToken.None); |
| 313 | |
| 314 | Assert.NotNull(operationId); |
| 315 | Assert.NotEmpty(operationId); |
| 316 | |
| 317 | Console.WriteLine($"Team-wide message sent. Operation ID: {operationId}"); |
| 318 | } |
| 319 | |
| 320 | [Fact(Skip = "Batch operations require special permissions")] |
| 321 | public async Task SendMessageToListOfChannels() |
| 322 | { |
| 323 | string tenantId = Environment.GetEnvironmentVariable("TENANT_ID") ?? throw new InvalidOperationException("TENANT_ID environment variable not set"); |
| 324 | string channelId = Environment.GetEnvironmentVariable("TEST_CHANNELID") ?? throw new InvalidOperationException("TEST_CHANNELID environment variable not set"); |
| 325 | |
| 326 | CoreActivity activity = new() |
| 327 | { |
| 328 | Type = ActivityType.Message, |
| 329 | Properties = { { "text", $"Channel batch message from Automated tests at `{DateTime.UtcNow:s}`" } } |
| 330 | }; |
| 331 | |
| 332 | IList<TeamMember> channels = |
| 333 | [ |
| 334 | new TeamMember(channelId) |
| 335 | ]; |
| 336 | |
| 337 | string operationId = await _teamsClient.SendMessageToListOfChannelsAsync( |
| 338 | activity, |
| 339 | channels, |
| 340 | tenantId, |
| 341 | _serviceUrl, |
| 342 | _agenticIdentity, |
| 343 | cancellationToken: CancellationToken.None); |
| 344 | |
| 345 | Assert.NotNull(operationId); |
| 346 | Assert.NotEmpty(operationId); |
| 347 | |
| 348 | Console.WriteLine($"Channel batch message sent. Operation ID: {operationId}"); |
| 349 | } |
| 350 | |
| 351 | #endregion |
| 352 | |
| 353 | #region Batch Operation Management Tests |
| 354 | |
| 355 | [Fact(Skip = "Requires valid operation ID from batch operation")] |
| 356 | public async Task GetOperationState() |
| 357 | { |
| 358 | string operationId = Environment.GetEnvironmentVariable("TEST_OPERATION_ID") ?? throw new InvalidOperationException("TEST_OPERATION_ID environment variable not set"); |
| 359 | |
| 360 | BatchOperationState result = await _teamsClient.GetOperationStateAsync( |
| 361 | operationId, |
| 362 | _serviceUrl, |
| 363 | _agenticIdentity, |
| 364 | cancellationToken: CancellationToken.None); |
| 365 | |
| 366 | Assert.NotNull(result); |
| 367 | Assert.NotNull(result.State); |
| 368 | |
| 369 | Console.WriteLine($"Operation state for {operationId}:"); |
| 370 | Console.WriteLine($" - State: {result.State}"); |
| 371 | Console.WriteLine($" - Total Entries: {result.TotalEntriesCount}"); |
| 372 | if (result.StatusMap != null) |
| 373 | { |
| 374 | Console.WriteLine($" - Success: {result.StatusMap.Success}"); |
| 375 | Console.WriteLine($" - Failed: {result.StatusMap.Failed}"); |
| 376 | Console.WriteLine($" - Throttled: {result.StatusMap.Throttled}"); |
| 377 | Console.WriteLine($" - Pending: {result.StatusMap.Pending}"); |
| 378 | } |
| 379 | if (result.RetryAfter != null) |
| 380 | { |
| 381 | Console.WriteLine($" - Retry After: {result.RetryAfter}"); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | [Fact] |
| 386 | public async Task GetOperationState_FailsWithInvalidOperationId() |
| 387 | { |
| 388 | await Assert.ThrowsAsync<HttpRequestException>(() |
| 389 | => _teamsClient.GetOperationStateAsync("invalid-operation-id", _serviceUrl, _agenticIdentity)); |
| 390 | } |
| 391 | |
| 392 | [Fact(Skip = "Requires valid operation ID from batch operation")] |
| 393 | public async Task GetPagedFailedEntries() |
| 394 | { |
| 395 | string operationId = Environment.GetEnvironmentVariable("TEST_OPERATION_ID") ?? throw new InvalidOperationException("TEST_OPERATION_ID environment variable not set"); |
| 396 | |
| 397 | BatchFailedEntriesResponse result = await _teamsClient.GetPagedFailedEntriesAsync( |
| 398 | operationId, |
| 399 | _serviceUrl, |
| 400 | null, |
| 401 | _agenticIdentity, |
| 402 | cancellationToken: CancellationToken.None); |
| 403 | |
| 404 | Assert.NotNull(result); |
| 405 | |
| 406 | Console.WriteLine($"Failed entries for operation {operationId}:"); |
| 407 | if (result.FailedEntries != null && result.FailedEntries.Count > 0) |
| 408 | { |
| 409 | foreach (var entry in result.FailedEntries) |
| 410 | { |
| 411 | Console.WriteLine($" - Id: {entry.Id}, Error: {entry.Error}"); |
| 412 | } |
| 413 | } |
| 414 | else |
| 415 | { |
| 416 | Console.WriteLine(" No failed entries"); |
| 417 | } |
| 418 | |
| 419 | if (!string.IsNullOrWhiteSpace(result.ContinuationToken)) |
| 420 | { |
| 421 | Console.WriteLine($"Continuation token: {result.ContinuationToken}"); |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | [Fact(Skip = "Requires valid operation ID from batch operation")] |
| 426 | public async Task CancelOperation() |
| 427 | { |
| 428 | string operationId = Environment.GetEnvironmentVariable("TEST_OPERATION_ID") ?? throw new InvalidOperationException("TEST_OPERATION_ID environment variable not set"); |
| 429 | |
| 430 | await _teamsClient.CancelOperationAsync( |
| 431 | operationId, |
| 432 | _serviceUrl, |
| 433 | _agenticIdentity, |
| 434 | cancellationToken: CancellationToken.None); |
| 435 | |
| 436 | Console.WriteLine($"Operation {operationId} cancelled successfully"); |
| 437 | } |
| 438 | |
| 439 | #endregion |
| 440 | |
| 441 | #region Argument Validation Tests |
| 442 | |
| 443 | [Fact] |
| 444 | public async Task FetchChannelList_ThrowsOnNullTeamId() |
| 445 | { |
| 446 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 447 | => _teamsClient.FetchChannelListAsync(null!, _serviceUrl, _agenticIdentity)); |
| 448 | } |
| 449 | |
| 450 | [Fact] |
| 451 | public async Task FetchChannelList_ThrowsOnEmptyTeamId() |
| 452 | { |
| 453 | await Assert.ThrowsAsync<ArgumentException>(() |
| 454 | => _teamsClient.FetchChannelListAsync("", _serviceUrl, _agenticIdentity)); |
| 455 | } |
| 456 | |
| 457 | [Fact] |
| 458 | public async Task FetchChannelList_ThrowsOnNullServiceUrl() |
| 459 | { |
| 460 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 461 | => _teamsClient.FetchChannelListAsync("team-id", null!)); |
| 462 | } |
| 463 | |
| 464 | [Fact] |
| 465 | public async Task FetchTeamDetails_ThrowsOnNullTeamId() |
| 466 | { |
| 467 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 468 | => _teamsClient.FetchTeamDetailsAsync(null!, _serviceUrl, _agenticIdentity)); |
| 469 | } |
| 470 | |
| 471 | [Fact] |
| 472 | public async Task FetchMeetingInfo_ThrowsOnNullMeetingId() |
| 473 | { |
| 474 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 475 | => _teamsClient.FetchMeetingInfoAsync(null!, _serviceUrl, _agenticIdentity)); |
| 476 | } |
| 477 | |
| 478 | [Fact] |
| 479 | public async Task FetchParticipant_ThrowsOnNullMeetingId() |
| 480 | { |
| 481 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 482 | => _teamsClient.FetchParticipantAsync(null!, "participant", "tenant", _serviceUrl, _agenticIdentity)); |
| 483 | } |
| 484 | |
| 485 | [Fact] |
| 486 | public async Task FetchParticipant_ThrowsOnNullParticipantId() |
| 487 | { |
| 488 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 489 | => _teamsClient.FetchParticipantAsync("meeting", null!, "tenant", _serviceUrl, _agenticIdentity)); |
| 490 | } |
| 491 | |
| 492 | [Fact] |
| 493 | public async Task FetchParticipant_ThrowsOnNullTenantId() |
| 494 | { |
| 495 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 496 | => _teamsClient.FetchParticipantAsync("meeting", "participant", null!, _serviceUrl, _agenticIdentity)); |
| 497 | } |
| 498 | |
| 499 | [Fact] |
| 500 | public async Task SendMeetingNotification_ThrowsOnNullMeetingId() |
| 501 | { |
| 502 | var notification = new TargetedMeetingNotification(); |
| 503 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 504 | => _teamsClient.SendMeetingNotificationAsync(null!, notification, _serviceUrl, _agenticIdentity)); |
| 505 | } |
| 506 | |
| 507 | [Fact] |
| 508 | public async Task SendMeetingNotification_ThrowsOnNullNotification() |
| 509 | { |
| 510 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 511 | => _teamsClient.SendMeetingNotificationAsync("meeting", null!, _serviceUrl, _agenticIdentity)); |
| 512 | } |
| 513 | |
| 514 | [Fact] |
| 515 | public async Task SendMessageToListOfUsers_ThrowsOnNullActivity() |
| 516 | { |
| 517 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 518 | => _teamsClient.SendMessageToListOfUsersAsync(null!, [new TeamMember("id")], "tenant", _serviceUrl, _agenticIdentity)); |
| 519 | } |
| 520 | |
| 521 | [Fact] |
| 522 | public async Task SendMessageToListOfUsers_ThrowsOnNullMembers() |
| 523 | { |
| 524 | var activity = new CoreActivity { Type = ActivityType.Message }; |
| 525 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 526 | => _teamsClient.SendMessageToListOfUsersAsync(activity, null!, "tenant", _serviceUrl, _agenticIdentity)); |
| 527 | } |
| 528 | |
| 529 | [Fact] |
| 530 | public async Task SendMessageToListOfUsers_ThrowsOnEmptyMembers() |
| 531 | { |
| 532 | var activity = new CoreActivity { Type = ActivityType.Message }; |
| 533 | await Assert.ThrowsAsync<ArgumentException>(() |
| 534 | => _teamsClient.SendMessageToListOfUsersAsync(activity, [], "tenant", _serviceUrl, _agenticIdentity)); |
| 535 | } |
| 536 | |
| 537 | [Fact] |
| 538 | public async Task SendMessageToAllUsersInTenant_ThrowsOnNullActivity() |
| 539 | { |
| 540 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 541 | => _teamsClient.SendMessageToAllUsersInTenantAsync(null!, "tenant", _serviceUrl, _agenticIdentity)); |
| 542 | } |
| 543 | |
| 544 | [Fact] |
| 545 | public async Task SendMessageToAllUsersInTenant_ThrowsOnNullTenantId() |
| 546 | { |
| 547 | var activity = new CoreActivity { Type = ActivityType.Message }; |
| 548 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 549 | => _teamsClient.SendMessageToAllUsersInTenantAsync(activity, null!, _serviceUrl, _agenticIdentity)); |
| 550 | } |
| 551 | |
| 552 | [Fact] |
| 553 | public async Task SendMessageToAllUsersInTeam_ThrowsOnNullActivity() |
| 554 | { |
| 555 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 556 | => _teamsClient.SendMessageToAllUsersInTeamAsync(null!, "team", "tenant", _serviceUrl, _agenticIdentity)); |
| 557 | } |
| 558 | |
| 559 | [Fact] |
| 560 | public async Task SendMessageToAllUsersInTeam_ThrowsOnNullTeamId() |
| 561 | { |
| 562 | var activity = new CoreActivity { Type = ActivityType.Message }; |
| 563 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 564 | => _teamsClient.SendMessageToAllUsersInTeamAsync(activity, null!, "tenant", _serviceUrl, _agenticIdentity)); |
| 565 | } |
| 566 | |
| 567 | [Fact] |
| 568 | public async Task SendMessageToListOfChannels_ThrowsOnEmptyChannels() |
| 569 | { |
| 570 | var activity = new CoreActivity { Type = ActivityType.Message }; |
| 571 | await Assert.ThrowsAsync<ArgumentException>(() |
| 572 | => _teamsClient.SendMessageToListOfChannelsAsync(activity, [], "tenant", _serviceUrl, _agenticIdentity)); |
| 573 | } |
| 574 | |
| 575 | [Fact] |
| 576 | public async Task GetOperationState_ThrowsOnNullOperationId() |
| 577 | { |
| 578 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 579 | => _teamsClient.GetOperationStateAsync(null!, _serviceUrl, _agenticIdentity)); |
| 580 | } |
| 581 | |
| 582 | [Fact] |
| 583 | public async Task GetPagedFailedEntries_ThrowsOnNullOperationId() |
| 584 | { |
| 585 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 586 | => _teamsClient.GetPagedFailedEntriesAsync(null!, _serviceUrl, null, _agenticIdentity)); |
| 587 | } |
| 588 | |
| 589 | [Fact] |
| 590 | public async Task CancelOperation_ThrowsOnNullOperationId() |
| 591 | { |
| 592 | await Assert.ThrowsAsync<ArgumentNullException>(() |
| 593 | => _teamsClient.CancelOperationAsync(null!, _serviceUrl, _agenticIdentity)); |
| 594 | } |
| 595 | |
| 596 | #endregion |
| 597 | } |
| 598 | |