public static IFeature Create(ICommandParser commandParser, IKeyValueStore persistence, Configuration configuration)
        {
            var zendeskApi = new ErrorCatchingZendeskTicketApi(
                new ZendeskTicketApi(new CachedZendeskApi(new Time(), ReconnectingZendeskApi.CreateAsync(
                                                              async() => await ZendeskApi.CreateAsync(configuration.Get("redgate-id")), new Time()).Result)));

            var zendeskTicketTracker   = new ZendeskTicketTracker(commandParser, persistence, zendeskApi);
            var zendeskTicketProcessor = new ZendeskTicketProcessor(zendeskApi);

            return(new BasicFeature("zdtracker", "track comments added to zendesk tickets", "use `track ZD#12345` to start tracking a zendesk ticket in the current channel",
                                    new CompositeMessageProcessor(zendeskTicketProcessor, zendeskTicketTracker)));
        }
示例#2
0
        public void BacksOffAfterThrowingException()
        {
            var underlying = new Mock <IZendeskApi>(MockBehavior.Strict);
            var time       = new Mock <ITime>();

            time.Setup(x => x.Now).Returns(DateTime.Now);

            underlying.Setup(x => x.Ticket("12345")).Throws <WebException>();

            var api = ReconnectingZendeskApi.CreateAsync(() => Task.FromResult(underlying.Object), time.Object).Result;

            Assert.Catch(() => { var foo = api.Ticket("12345").Result; });
            Assert.Null(api.Ticket("12345").Result);

            time.Setup(x => x.Now).Returns(DateTime.Now + 3.Minutes());

            Assert.Catch(() => { var foo = api.Ticket("12345").Result; });
        }