Exemple #1
0
        public async Task Can_Post_Simple_Error_Message()
        {
            // Arrange
            IWebhookService webhookService = new WebhookService();

            // Act
            bool result = await webhookService.PostAsync("https://webhooks.gitter.im/e/cdf519d88a935d54a6d2", "A simple error message", MessageLevel.Error);

            // Assert
            Assert.IsTrue(result);
        }
        private static GitterChatMessageResult PostToIncomingWebHook(ICakeContext context, string message, GitterChatMessageSettings messageSettings)
        {
            context.Verbose("Posting to incoming webhook {0}...", string.Concat(messageSettings.IncomingWebHookUrl.TrimEnd('/').Reverse().SkipWhile(c => c != '/').Reverse()));

            var gitterWebHookService = new WebhookService();
            var result = gitterWebHookService.PostAsync(messageSettings.IncomingWebHookUrl, message, messageSettings.MessageLevel == GitterMessageLevel.Error ? MessageLevel.Error : MessageLevel.Info);

            var parsedResult = new GitterChatMessageResult(result.Result, DateTime.UtcNow.ToString("u"), string.Empty);

            context.Debug("Result parsed: {0}", parsedResult);

            return(parsedResult);
        }