示例#1
0
        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);
        }
示例#2
0
        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"));
        }
示例#3
0
        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"));
        }