Exemplo n.º 1
0
        public void WebhookUrlWithEmptyString()
        {
            var config = new TriggrConfig();

            config.Url     = string.Empty;
            config.Webhook = true;

            var mock = new Mock <IOptions <TriggrConfig> >();

            mock.Setup(i => i.Value).Returns(config);

            WebhookService service = new WebhookService(null, mock.Object, null);
            Action         action  = () => service.WebhookUrl();

            Assert.ThrowsAny <UriFormatException>(action);
        }
Exemplo n.º 2
0
        public void WebhookUrlWithValid()
        {
            var config = new TriggrConfig();

            config.Url     = "http://www.triggr.com/";
            config.Webhook = true;

            var mock = new Mock <IOptions <TriggrConfig> >();

            mock.Setup(i => i.Value).Returns(config);

            WebhookService service = new WebhookService(null, mock.Object, null);

            var result = service.WebhookUrl();

            Assert.Equal(config.Url + "GithubWebhook/HandlerForPush", result);
        }
Exemplo n.º 3
0
        public void WebhookUrlWithLocalhostAndNoProtocol()
        {
            var config = new TriggrConfig();

            config.Url     = "localhost";
            config.Webhook = true;

            var mock = new Mock <IOptions <TriggrConfig> >();

            mock.Setup(i => i.Value).Returns(config);

            WebhookService service = new WebhookService(null, mock.Object, null);

            var result = service.WebhookUrl();

            Assert.Equal($"http://{config.Url}/GithubWebhook/HandlerForPush", result);
        }