diff --git a/tests/Microsoft.Bot.Builder.Tests/Teams/TeamsActivityHandlerTests.cs b/tests/Microsoft.Bot.Builder.Tests/Teams/TeamsActivityHandlerTests.cs index f13d0326d0..092209dfc3 100644 --- a/tests/Microsoft.Bot.Builder.Tests/Teams/TeamsActivityHandlerTests.cs +++ b/tests/Microsoft.Bot.Builder.Tests/Teams/TeamsActivityHandlerTests.cs @@ -1270,6 +1270,80 @@ void CaptureSend(Activity[] arg) Assert.Equal("10101010", activitiesToSend[0].Text); } + [Fact] + public async Task TestMeetingParticipantsAddedEvent() + { + // Arrange + var activity = new Activity + { + ChannelId = Channels.Msteams, + Type = ActivityTypes.Event, + Name = "application/vnd.microsoft.meetingParticipantsAdded", + Value = JObject.Parse(@"{ + ParticipantsAdded: [ + {Id: 'id', Name: 'name'} + ] + }"), + }; + + Activity[] activitiesToSend = null; + void CaptureSend(Activity[] arg) + { + activitiesToSend = arg; + } + + var turnContext = new TurnContext(new SimpleAdapter(CaptureSend), activity); + + // Act + var bot = new TestActivityHandler(); + await ((IBot)bot).OnTurnAsync(turnContext); + + // Assert + Assert.Equal(2, bot.Record.Count); + Assert.Equal("OnEventActivityAsync", bot.Record[0]); + Assert.Equal("OnTeamsMeetingParticipantsAddedAsync", bot.Record[1]); + Assert.NotNull(activitiesToSend); + Assert.Single(activitiesToSend); + Assert.Equal("id", activitiesToSend[0].Text); + } + + [Fact] + public async Task TestMeetingParticipantsRemovedEvent() + { + // Arrange + var activity = new Activity + { + ChannelId = Channels.Msteams, + Type = ActivityTypes.Event, + Name = "application/vnd.microsoft.meetingParticipantsRemoved", + Value = JObject.Parse(@"{ + ParticipantsRemoved: [ + {Id: 'id', Name: 'name'} + ] + }"), + }; + + Activity[] activitiesToSend = null; + void CaptureSend(Activity[] arg) + { + activitiesToSend = arg; + } + + var turnContext = new TurnContext(new SimpleAdapter(CaptureSend), activity); + + // Act + var bot = new TestActivityHandler(); + await ((IBot)bot).OnTurnAsync(turnContext); + + // Assert + Assert.Equal(2, bot.Record.Count); + Assert.Equal("OnEventActivityAsync", bot.Record[0]); + Assert.Equal("OnTeamsMeetingParticipantsRemovedAsync", bot.Record[1]); + Assert.NotNull(activitiesToSend); + Assert.Single(activitiesToSend); + Assert.Equal("id", activitiesToSend[0].Text); + } + [Fact] public async Task TestMessageUpdateActivityTeamsMessageEdit() { @@ -1536,6 +1610,20 @@ protected override Task OnTeamsReadReceiptAsync(ReadReceiptInfo readReceiptInfo, return Task.CompletedTask; } + protected override Task OnTeamsMeetingParticipantsAddedAsync(MeetingParticipantsAddedEventDetails meeting, ITurnContext turnContext, CancellationToken cancellationToken) + { + Record.Add(MethodBase.GetCurrentMethod().Name); + turnContext.SendActivityAsync(meeting.ParticipantsAdded[0].Id); + return base.OnTeamsMeetingParticipantsAddedAsync(meeting, turnContext, cancellationToken); + } + + protected override Task OnTeamsMeetingParticipantsRemovedAsync(MeetingParticipantsRemovedEventDetails meeting, ITurnContext turnContext, CancellationToken cancellationToken) + { + Record.Add(MethodBase.GetCurrentMethod().Name); + turnContext.SendActivityAsync(meeting.ParticipantsRemoved[0].Id); + return base.OnTeamsMeetingParticipantsRemovedAsync(meeting, turnContext, cancellationToken); + } + // Invoke protected override Task OnInvokeActivityAsync(ITurnContext turnContext, CancellationToken cancellationToken) { diff --git a/tests/Microsoft.Bot.Schema.Tests/Teams/MeetingParticipantsAddedEventDetailsTests.cs b/tests/Microsoft.Bot.Schema.Tests/Teams/MeetingParticipantsAddedEventDetailsTests.cs new file mode 100644 index 0000000000..9063f78116 --- /dev/null +++ b/tests/Microsoft.Bot.Schema.Tests/Teams/MeetingParticipantsAddedEventDetailsTests.cs @@ -0,0 +1,48 @@ +// Copyright(c) Microsoft Corporation.All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using Microsoft.Bot.Schema.Teams; +using Xunit; + +namespace Microsoft.Bot.Schema.Tests.Teams +{ + public class MeetingParticipantsAddedEventDetailsTests + { + [Fact] + public void MeetingParticipantsAddedEventDetailsInits() + { + // Arrange + var meetingId = "meetingId"; + var meetingJoinUrl = new Uri("http://meetingJoinUrl"); + var meetingTitle = "meetingTitle"; + var meetingType = "meetingType"; + var participant = new TeamsChannelAccount("id", "name", "givenName", "surname", "email", "userPrincipalName"); + var participantsAdded = new List() { participant }; + + // Act + var meeting = new MeetingParticipantsAddedEventDetails(meetingId, meetingJoinUrl, meetingTitle, meetingType, participantsAdded); + + // Assert + Assert.NotNull(meeting); + Assert.IsType(meeting); + Assert.Equal(meetingId, meeting.Id); + Assert.Equal(meetingJoinUrl, meeting.JoinUrl); + Assert.Equal(meetingTitle, meeting.Title); + Assert.Equal(meetingType, meeting.MeetingType); + Assert.StrictEqual(participantsAdded, meeting.ParticipantsAdded); + } + + [Fact] + public void MeetingParticipantsAddedEventDetailsInitsWithNoArgs() + { + // Act + var meeting = new MeetingParticipantsAddedEventDetails(); + + // Assert + Assert.NotNull(meeting); + Assert.IsType(meeting); + } + } +} diff --git a/tests/Microsoft.Bot.Schema.Tests/Teams/MeetingParticipantsRemovedEventDetailsTests.cs b/tests/Microsoft.Bot.Schema.Tests/Teams/MeetingParticipantsRemovedEventDetailsTests.cs new file mode 100644 index 0000000000..b5234b4305 --- /dev/null +++ b/tests/Microsoft.Bot.Schema.Tests/Teams/MeetingParticipantsRemovedEventDetailsTests.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using Microsoft.Bot.Schema.Teams; +using Xunit; + +namespace Microsoft.Bot.Schema.Tests.Teams +{ + public class MeetingParticipantsRemovedEventDetailsTests + { + [Fact] + public void MeetingParticipantsRemovedEventDetailsInits() + { + // Arrange + var meetingId = "meetingId"; + var meetingJoinUrl = new Uri("http://meetingJoinUrl"); + var meetingTitle = "meetingTitle"; + var meetingType = "meetingType"; + var participant = new TeamsChannelAccount("id", "name", "givenName", "surname", "email", "userPrincipalName"); + var participantsRemoved = new List() { participant }; + + // Act + var meeting = new MeetingParticipantsRemovedEventDetails(meetingId, meetingJoinUrl, meetingTitle, meetingType, participantsRemoved); + + // Assert + Assert.NotNull(meeting); + Assert.IsType(meeting); + Assert.Equal(meetingId, meeting.Id); + Assert.Equal(meetingJoinUrl, meeting.JoinUrl); + Assert.Equal(meetingTitle, meeting.Title); + Assert.Equal(meetingType, meeting.MeetingType); + Assert.StrictEqual(participantsRemoved, meeting.ParticipantsRemoved); + } + + [Fact] + public void MeetingParticipantsRemovedEventDetailsInitsWithNoArgs() + { + // Act + var meeting = new MeetingParticipantsRemovedEventDetails(); + + // Assert + Assert.NotNull(meeting); + Assert.IsType(meeting); + } + } +}