public async Task TestSendMessageToTeamsChannelAsync()
        {
            var baseUri          = new Uri("https://test.coffee");
            var customHttpClient = new HttpClient(new RosterHttpMessageHandler(), false);

            // Set a special base address so then we can make sure the connector client is honoring this http client
            customHttpClient.BaseAddress = baseUri;
            var connectorClient = new ConnectorClient(new Uri("https://test.coffee"), new MicrosoftAppCredentials("big-guid-here", "appPasswordHere"), customHttpClient);

            var activity = new Activity
            {
                Type        = "message",
                Text        = "Test-SendMessageToTeamsChannelAsync",
                ChannelId   = Channels.Msteams,
                ChannelData = new TeamsChannelData
                {
                    Team = new TeamInfo
                    {
                        Id = "team-id",
                    },
                },
            };

            var turnContext = new TurnContext(new BotFrameworkAdapter(new SimpleCredentialProvider("big-guid-here", "appPasswordHere"), customHttpClient: customHttpClient), activity);

            turnContext.TurnState.Add <IConnectorClient>(connectorClient);
            turnContext.Activity.ServiceUrl = "https://test.coffee";
            var handler = new TestTeamsActivityHandler();
            await handler.OnTurnAsync(turnContext);
        }
        public async Task TestTeamGetMembersAsync()
        {
            var baseUri          = new Uri("https://test.coffee");
            var customHttpClient = new HttpClient(new RosterHttpMessageHandler());

            // Set a special base address so then we can make sure the connector client is honoring this http client
            customHttpClient.BaseAddress = baseUri;
            var connectorClient = new ConnectorClient(new Uri("http://localhost/"), new MicrosoftAppCredentials(string.Empty, string.Empty), customHttpClient);

            var activity = new Activity
            {
                Type        = "message",
                Text        = "Test-Team-GetMembersAsync",
                ChannelId   = Channels.Msteams,
                ChannelData = new TeamsChannelData
                {
                    Team = new TeamInfo
                    {
                        Id = "team-id",
                    },
                },
            };

            var turnContext = new TurnContext(new SimpleAdapter(), activity);

            turnContext.TurnState.Add <IConnectorClient>(connectorClient);

            var handler = new TestTeamsActivityHandler();
            await handler.OnTurnAsync(turnContext);
        }
Esempio n. 3
0
        public async Task TestGetParticipantAsync()
        {
            var baseUri          = new Uri("https://test.coffee");
            var customHttpClient = new HttpClient(new RosterHttpMessageHandler());

            // Set a special base address so then we can make sure the connector client is honoring this http client
            customHttpClient.BaseAddress = baseUri;
            var connectorClient = new ConnectorClient(new Uri("http://localhost/"), new MicrosoftAppCredentials(string.Empty, string.Empty), customHttpClient);

            var activity = new Activity
            {
                Type      = "message",
                Text      = "Test-GetParticipantAsync",
                ChannelId = Channels.Msteams,
                From      = new ChannelAccount {
                    AadObjectId = "participantId-1"
                },
                ChannelData = new TeamsChannelData
                {
                    Meeting = new TeamsMeetingInfo
                    {
                        Id = "meetingId-1"
                    },
                    Tenant = new TenantInfo
                    {
                        Id = "tenantId-1"
                    },
                },
                ServiceUrl = "https://test.coffee",
            };

            var turnContext = new TurnContext(new SimpleAdapter(), activity);

            turnContext.TurnState.Add <IConnectorClient>(connectorClient);
            var handler = new TestTeamsActivityHandler();
            await handler.OnTurnAsync(turnContext);
        }