public static INotifier Create(NotifierType type, ILogger logger, IConfigurationSection section) { NotifierFactory factory; switch (type) { case NotifierType.Pushbullet: factory = new PushbulletFactory(); break; case NotifierType.Webhook: factory = new WebhookFactory(); break; case NotifierType.Email: factory = new EmailFactory(); break; case NotifierType.Telegram: factory = new TelegramFactory(); break; default: throw new NotImplementedException(type.ToString()); } INotifier notifier = factory.Create(logger, section); notifier.Cameras = section.GetSection("Cameras").Get <List <string> >(); return(notifier); }
public void GetServiceWithUnknownUrl() { var mockGithub = new Mock <IWebhookService>(); var mockBitbucket = new Mock <IWebhookService>(); mockGithub.Setup(i => i.IsSupport("www.bitbucket.com")).Returns(false); mockBitbucket.Setup(i => i.IsSupport("www.bitbucket.com")).Returns(false); List <IWebhookService> services = new List <IWebhookService>() { mockGithub.Object, mockBitbucket.Object }; WebhookFactory factory = new WebhookFactory(services); Assert.Null(factory.GetService("www.bitbucket.com")); }
public void IsSupportedFalseTest() { var mockGithub = new Mock <IWebhookService>(); var mockBitbucket = new Mock <IWebhookService>(); mockGithub.Setup(i => i.IsSupport("www.githu1b.com")).Returns(false); mockBitbucket.Setup(i => i.IsSupport("www.githu1b.com")).Returns(false); List <IWebhookService> services = new List <IWebhookService>() { mockGithub.Object, mockBitbucket.Object }; WebhookFactory factory = new WebhookFactory(services); Assert.False(factory.IsSupported("www.githu1b.com")); }