예제 #1
0
 public void SetUp()
 {
     this.subLog                  = Substitute.For <ILog>();
     this.subRevokeListener       = Substitute.For <IRevokeListener>();
     this.subRevokeKeyIndexer     = Substitute.For <IRevokeKeyIndexer>();
     this.subFuncRevokeKeyIndexer = Substitute.For <IRevokeKeyIndexerFactory>();
     subFuncRevokeKeyIndexer.Create().Returns(_ => subRevokeKeyIndexer);
     this.subFuncRevokeNotifierConfig = () => new RevokeNotifierConfig {
         CleanupIntervalInSec = 1
     };
 }
예제 #2
0
        public RevokeNotifier(ILog logger,
                              IRevokeListener revokeListener,
                              IRevokeKeyIndexerFactory indexerFactory,
                              Func <RevokeNotifierConfig> configFunc)
        {
            _logger        = logger;
            _revokeIndexer = indexerFactory.Create();
            ITargetBlock <string> actionBlock = new ActionBlock <string>(OnRevoke); //TODO: move to new class

            _configFunc = configFunc;
            var config = _configFunc();

            _timerInterval = config.CleanupIntervalInSec;
            var ts = TimeSpan.FromSeconds(_timerInterval);

            _timer = new Timer(RevokeNotifierTimerCallback, null, ts, ts);
            revokeListener.RevokeSource.LinkTo(actionBlock);
        }