Ejemplo n.º 1
0
        private static async Task SendMessageTo(string opponentUserId, string challengerName)
        {
            var oauthToken = await GetOAuthToken();

            var payload = new Dictionary <string, string> {
                { "from", challengerName }
            };

            var messages      = new SkillMessageClient(SkillMessageClient.EuropeEndpoint, oauthToken);
            var messageToSend = new Alexa.NET.SkillMessaging.Message(payload, 300);

            await messages.Send(messageToSend, opponentUserId);
        }
Ejemplo n.º 2
0
        public async Task HandlesResponseHeaderCorrectly()
        {
            var handler = new ActionMessageHandler(req =>
            {
                var response = new HttpResponseMessage(HttpStatusCode.Accepted);
                response.Headers.Add("X-Amzn-RequestID", "xxx");
                return(response);
            });

            var client = new HttpClient(handler)
            {
                BaseAddress = new Uri(SkillMessageClient.EuropeEndpoint, UriKind.Absolute)
            };
            var messageRequest = new SkillMessageClient(client);

            var message = new Message(TestMessageData, 60);

            Assert.Equal("xxx", await messageRequest.Send(message, UserId));
        }
Ejemplo n.º 3
0
        public async Task SendsCorrectRequest()
        {
            var handler = new ActionMessageHandler(req =>
            {
                Assert.Equal(HttpMethod.Post, req.Method);
                Assert.Equal(new Uri(new Uri(SkillMessageClient.EuropeEndpoint), UserId).ToString(), req.RequestUri.ToString());
                var response = new HttpResponseMessage(HttpStatusCode.Accepted);
                response.Headers.Add("X-Amzn-RequestID", "xxx");
                return(response);
            });

            var client = new HttpClient(handler)
            {
                BaseAddress = new Uri(SkillMessageClient.EuropeEndpoint, UriKind.Absolute)
            };
            var messageRequest = new SkillMessageClient(client);

            var message = new Message(TestMessageData, 60);
            await messageRequest.Send(message, UserId);
        }
Ejemplo n.º 4
0
 public async Task SendThrowsExceptionIfUserIdIsEmpty()
 {
     var message        = new Message(TestMessageData, 30);
     var messageRequest = new SkillMessageClient(new HttpClient());
     await Assert.ThrowsAsync <SkillMessagingException>(() => messageRequest.Send(message, string.Empty));
 }
Ejemplo n.º 5
0
 public async Task SendThrowsExceptionIfExpiryIsZero()
 {
     var message        = new Message(TestMessageData, 0);
     var messageRequest = new SkillMessageClient(new HttpClient());
     await Assert.ThrowsAsync <SkillMessagingException>(() => messageRequest.Send(message, UserId));
 }