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); }
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); }
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); }