Exemplo n.º 1
0
 public void SetUp()
 {
     task = MockRepository.GenerateMock<IWantToBeRun>();
     sleeper = MockRepository.GenerateMock<ISleeper>();
     stopper = MockRepository.GenerateMock<IStopper>();
     timer = new Timer(task, sleeper,stopper);
 }
Exemplo n.º 2
0
 public static void StartWatcher(WatcherType watcherType, string fileName, IStreamReader streamReader, ISleeper sleeper)
 {
     var watcher = CreateWatcherInternal(watcherType, streamReader, sleeper);
     watcher.Configuration = GetDefaultFileWatcherConfiguration(fileName);
     AddWatcherToPool(watcher);
     watcher.Start();
 }
Exemplo n.º 3
0
 public virtual void SetUp()
 {
     _sleeper = _sleeper.Fake();
     _validStateTimeoutProvider = _validStateTimeoutProvider.Fake();
     _taskScheduler             = new DeterministicTaskScheduler();
     _sut = new ValidStateFactory <Department>(_validStateTimeoutProvider, _sleeper, _taskScheduler);
 }
Exemplo n.º 4
0
 public static void Main()
 {
     var           employee     = new Employee("worker");
     var           robot        = new Robot("01", 500);
     ISleeper      sleeper      = employee;
     IRechargeable rechargeable = robot;
 }
 /// <summary>The with sleeper.</summary>
 /// <param name="sleeper">The sleeper.</param>
 /// <returns>The Spring.Retry.Retry.Backoff.FixedBackOffPolicy.</returns>
 public ISleepingBackOffPolicy WithSleeper(ISleeper sleeper)
 {
     var res = new FixedBackOffPolicy();
     res.BackOffPeriod = this.BackOffPeriod;
     res.Sleeper = sleeper;
     return res;
 }
Exemplo n.º 6
0
 public virtual void SetUp()
 {
     _projectionSystem = _projectionSystem.Fake();
     _timeout          = TimeSpan.FromMilliseconds(200);
     _sleeper          = _sleeper.Fake();
     _taskScheduler    = new DeterministicTaskScheduler();
     _sut = new ValidState <Department>(_projectionSystem, _timeout, _sleeper, _taskScheduler);
 }
        /// <summary>The with sleeper.</summary>
        /// <param name="sleeper">The sleeper.</param>
        /// <returns>The Spring.Retry.Retry.Backoff.ExponentialBackOffPolicy.</returns>
        public ExponentialBackOffPolicy WithSleeper(ISleeper sleeper)
        {
            var res = this.NewInstance();

            this.CloneValues(res);
            res.Sleeper = sleeper;
            return(res);
        }
Exemplo n.º 8
0
        /// <summary>The with sleeper.</summary>
        /// <param name="sleeper">The sleeper.</param>
        /// <returns>The Spring.Retry.Retry.Backoff.FixedBackOffPolicy.</returns>
        public ISleepingBackOffPolicy WithSleeper(ISleeper sleeper)
        {
            var res = new FixedBackOffPolicy();

            res.BackOffPeriod = this.BackOffPeriod;
            res.Sleeper       = sleeper;
            return(res);
        }
Exemplo n.º 9
0
        public static void StartWatcher(WatcherType watcherType, FileWatchConfiguration fileWatchConfiguration,
            IStreamReader streamReader, ISleeper sleeper)
        {
            var watcher = CreateWatcherInternal(watcherType, streamReader, sleeper);
            watcher.Configuration = fileWatchConfiguration;

            AddWatcherToPool(watcher);
            watcher.Start();
        }
Exemplo n.º 10
0
        public WorkerInstance(Configuration config)
        {
            Logger.Info(Logger.Separator);
            Sleeper = new FakeSleeper();

            TokenSource             = new CancellationTokenSource();
            MainThread              = new Thread(() => this.Run(TokenSource.Token));
            MainThread.IsBackground = false;
        }
Exemplo n.º 11
0
 private static IWatcher CreateWatcherInternal(WatcherType watcherType, IStreamReader streamReader, ISleeper sleeper)
 {
     switch (watcherType)
     {
         case WatcherType.File:
             return new FileWatcher(streamReader, sleeper);
         default:
             throw new NotImplementedException($"Factory method for {watcherType} not implemented");
     }
 }
 public XentoolsUpdate(ISleeper sleeper, IDownloader downloader, IChecksumValidator checksumValidator, IUnzipper unzipper, IInstaller installer, IFinalizer finalizer, IServiceRestarter _serviceRestarter,IConnectionChecker connectionChecker, IAgentUpdateMessageHandler agentUpdateMessageHandler, ILogger logger)
 {
     _sleeper = sleeper;
     _downloader = downloader;
     _checksumValidator = checksumValidator;
     _unzipper = unzipper;
     _installer = installer;
     _finalizer = finalizer;
     this._serviceRestarter = _serviceRestarter;
     _connectionChecker = connectionChecker;
     _agentUpdateMessageHandler = agentUpdateMessageHandler;
     _logger = logger;
 }
 public XentoolsUpdate(ISleeper sleeper, IDownloader downloader, IChecksumValidator checksumValidator, IUnzipper unzipper, IInstaller installer, IFinalizer finalizer, IServiceRestarter _serviceRestarter, IConnectionChecker connectionChecker, IAgentUpdateMessageHandler agentUpdateMessageHandler, ILogger logger)
 {
     _sleeper                   = sleeper;
     _downloader                = downloader;
     _checksumValidator         = checksumValidator;
     _unzipper                  = unzipper;
     _installer                 = installer;
     _finalizer                 = finalizer;
     this._serviceRestarter     = _serviceRestarter;
     _connectionChecker         = connectionChecker;
     _agentUpdateMessageHandler = agentUpdateMessageHandler;
     _logger = logger;
 }
Exemplo n.º 14
0
 public EnsureMinAgentUpdater(ISleeper sleeper, IUnzipper unzipper, IFileCopier fileCopier, IFinalizer finalizer, IServiceStopper serviceStopper, IServiceStarter serviceStarter, ILogger logger, IBackupUpdater backupUpdater, IExtractEmbededResource extractEmbededResource, IVersionChecker versionChecker)
 {
     _sleeper                = sleeper;
     _unzipper               = unzipper;
     _fileCopier             = fileCopier;
     _finalizer              = finalizer;
     _serviceStopper         = serviceStopper;
     _serviceStarter         = serviceStarter;
     _logger                 = logger;
     _backupUpdater          = backupUpdater;
     _extractEmbededResource = extractEmbededResource;
     _versionChecker         = versionChecker;
 }
Exemplo n.º 15
0
 public UpdaterUpdate(ISleeper sleeper, IDownloader downloader, IChecksumValidator checksumValidator, IUnzipper unzipper, IFileCopier fileCopier, IFinalizer finalizer, IServiceStopper serviceStopper, IServiceStarter serviceStarter, IConnectionChecker connectionChecker, IAgentUpdateMessageHandler agentUpdateMessageHandler, ILogger logger)
 {
     _sleeper                   = sleeper;
     _downloader                = downloader;
     _checksumValidator         = checksumValidator;
     _unzipper                  = unzipper;
     _fileCopier                = fileCopier;
     _finalizer                 = finalizer;
     _serviceStopper            = serviceStopper;
     _serviceStarter            = serviceStarter;
     _connectionChecker         = connectionChecker;
     _agentUpdateMessageHandler = agentUpdateMessageHandler;
     _logger = logger;
 }
 public UpdaterUpdate(ISleeper sleeper, IDownloader downloader, IChecksumValidator checksumValidator, IUnzipper unzipper, IFileCopier fileCopier, IFinalizer finalizer, IServiceStopper serviceStopper, IServiceStarter serviceStarter, IConnectionChecker connectionChecker, IAgentUpdateMessageHandler agentUpdateMessageHandler, ILogger logger)
 {
     _sleeper = sleeper;
     _downloader = downloader;
     _checksumValidator = checksumValidator;
     _unzipper = unzipper;
     _fileCopier = fileCopier;
     _finalizer = finalizer;
     _serviceStopper = serviceStopper;
     _serviceStarter = serviceStarter;
     _connectionChecker = connectionChecker;
     _agentUpdateMessageHandler = agentUpdateMessageHandler;
     _logger = logger;
 }
 public ValidStateFactory(IValidStateTimeoutProvider <TItem> validStateTimeoutProvider, ISleeper sleeper, TaskScheduler taskScheduler)
 {
     if (validStateTimeoutProvider == null)
     {
         throw new ArgumentNullException(nameof(validStateTimeoutProvider));
     }
     if (sleeper == null)
     {
         throw new ArgumentNullException(nameof(sleeper));
     }
     if (taskScheduler == null)
     {
         throw new ArgumentNullException(nameof(taskScheduler));
     }
     _validStateTimeoutProvider = validStateTimeoutProvider;
     _sleeper       = sleeper;
     _taskScheduler = taskScheduler;
 }
        public void Setup()
        {
            _agentUpdateInfo = "http://something.com/file.zip,544564abc453de787ad";

            _downloader                = MockRepository.GenerateMock <IDownloader>();
            _checksumValidator         = MockRepository.GenerateMock <IChecksumValidator>();
            _unzipper                  = MockRepository.GenerateMock <IUnzipper>();
            _installer                 = MockRepository.GenerateMock <IInstaller>();
            _finalizer                 = MockRepository.GenerateMock <IFinalizer>();
            _connectionChecker         = MockRepository.GenerateMock <IConnectionChecker>();
            _sleeper                   = MockRepository.GenerateMock <ISleeper>();
            _logger                    = MockRepository.GenerateMock <ILogger>();
            _serviceRestarter          = MockRepository.GenerateMock <IServiceRestarter>();
            _agentUpdateMessageHandler = new AgentUpdateMessageHandler();

            _logger.Stub(x => x.Log(Arg <string> .Is.Anything));

            _xentoolsUpdate = new XentoolsUpdate(_sleeper, _downloader, _checksumValidator, _unzipper, _installer, _finalizer, _serviceRestarter, _connectionChecker, _agentUpdateMessageHandler, _logger);
        }
        public void Setup()
        {
            _agentUpdateInfo = "http://something.com/file.zip,544564abc453de787ad";

            _downloader = MockRepository.GenerateMock<IDownloader>();
            _checksumValidator = MockRepository.GenerateMock<IChecksumValidator>();
            _unzipper = MockRepository.GenerateMock<IUnzipper>();
            _installer = MockRepository.GenerateMock<IInstaller>();
            _finalizer = MockRepository.GenerateMock<IFinalizer>();
            _connectionChecker = MockRepository.GenerateMock<IConnectionChecker>();
            _sleeper = MockRepository.GenerateMock<ISleeper>();
            _logger = MockRepository.GenerateMock<ILogger>();
            _serviceRestarter = MockRepository.GenerateMock<IServiceRestarter>();
            _agentUpdateMessageHandler = new AgentUpdateMessageHandler();

            _logger.Stub(x => x.Log(Arg<string>.Is.Anything));

            _xentoolsUpdate = new XentoolsUpdate(_sleeper, _downloader, _checksumValidator, _unzipper, _installer, _finalizer, _serviceRestarter, _connectionChecker, _agentUpdateMessageHandler, _logger);
        }
Exemplo n.º 20
0
 public ValidState(IProjectionSystem <TItem> projectionSystem, TimeSpan timeout, ISleeper sleeper, TaskScheduler taskScheduler)
 {
     if (projectionSystem == null)
     {
         throw new ArgumentNullException(nameof(projectionSystem));
     }
     if (sleeper == null)
     {
         throw new ArgumentNullException(nameof(sleeper));
     }
     if (taskScheduler == null)
     {
         throw new ArgumentNullException(nameof(taskScheduler));
     }
     if (timeout <= TimeSpan.Zero)
     {
         throw new ArgumentException("An invalid projection timeout has been specified.", nameof(timeout));
     }
     _projectionSystem = projectionSystem;
     _timeout          = timeout;
     _sleeper          = sleeper;
     _taskScheduler    = taskScheduler;
 }
Exemplo n.º 21
0
        public static IProjectionSystem <Department> Create(TimeSpan expiration, IProjectionDataService <Department> projectionDataService, ISleeper sleeper)
        {
            var systemClock   = new RealSystemClock();
            var traceLogger   = new ConsoleTraceLogger(systemClock);
            var taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            var createProjectionLockFactory = new RealSyncLockFactory(new SemaphoreSlim(1));
            var updateProjectionLockFactory = new RealSyncLockFactory(new SemaphoreSlim(1));
            var getProjectionLockFactory    = new RealSyncLockFactory(new SemaphoreSlim(1));
            var transitionGuardFactory      = new StateTransitionGuardFactory();
            var timeoutProvider             = new ValidStateTimeoutProvider <Department>(expiration);

            return(new ProjectionSystem <Department>(
                       new LoggingStateTransitionOrchestrator <Department>(new StateTransitionOrchestrator <Department>(transitionGuardFactory), traceLogger),
                       new UninitialisedStateFactory <Department>(),
                       new CreatingStateFactory <Department>(projectionDataService, createProjectionLockFactory),
                       new ValidStateFactory <Department>(timeoutProvider, sleeper, taskScheduler),
                       new ExpiredStateFactory <Department>(),
                       new UpdatingStateFactory <Department>(projectionDataService, updateProjectionLockFactory, taskScheduler),
                       getProjectionLockFactory));
        }
 /// <summary>The with sleeper.</summary>
 /// <param name="sleeper">The sleeper.</param>
 /// <returns>The Spring.Retry.Retry.Backoff.ExponentialBackOffPolicy.</returns>
 public ExponentialBackOffPolicy WithSleeper(ISleeper sleeper)
 {
     var res = this.NewInstance();
     this.CloneValues(res);
     res.Sleeper = sleeper;
     return res;
 }
Exemplo n.º 23
0
 public LoopingTaskRunner(ISleeper sleeper)
 {
     _sleeper = sleeper;
 }
 public CacheDeleter(IParameterHelper parameterHelper, IFileSystem fileSystem, ISleeper sleeper)
 {
     this.parameterHelper = parameterHelper;
     this.fileSystem      = fileSystem;
     this.sleeper         = sleeper;
 }
 public Worker(ISleeper sleeper, ILogger <Worker> logger)
 {
     this.sleeper = sleeper;
     this.logger  = logger;
 }
 public ScreenDataRetriever(ISleeper sleeper, IScreenshotCapturer screenshotCapturer)
 {
     Sleeper            = sleeper;
     ScreenshotCapturer = screenshotCapturer;
 }
Exemplo n.º 27
0
        //====== ctors

        public GameRoot(HardwareAccessLayer hal, ISleeper sleeper, ILogger logger)
        {
            this.hal     = Verify.NotNull(hal, nameof(hal));
            this.sleeper = Verify.NotNull(sleeper, nameof(sleeper));
            this.logger  = Verify.NotNull(logger, nameof(logger));
        }
Exemplo n.º 28
0
 public Timer(IWantToBeRun task, ISleeper sleeper,IStopper stopper)
 {
     _task = task;
     _sleeper = sleeper;
     _stopper = stopper;
 }
Exemplo n.º 29
0
 public Output(IConsole console, ISleeper sleeper)
 {
     _console = console;
     _sleeper = sleeper;
 }