Example #1
0
        public SyncManager(
            ISyncStateQueue queue,
            IStateMachineOrchestrator orchestrator,
            IAnalyticsService analyticsService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            ITimeService timeService,
            IStopwatchProvider stopwatchProvider)
        {
            Ensure.Argument.IsNotNull(queue, nameof(queue));
            Ensure.Argument.IsNotNull(orchestrator, nameof(orchestrator));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider));

            this.queue                = queue;
            this.orchestrator         = orchestrator;
            this.analyticsService     = analyticsService;
            this.lastTimeUsageStorage = lastTimeUsageStorage;
            this.timeService          = timeService;
            this.stopwatchProvider    = stopwatchProvider;

            progress           = new BehaviorSubject <SyncProgress>(SyncProgress.Unknown);
            ProgressObservable = progress.AsObservable();

            errors = new Subject <Exception>();
            Errors = errors.AsObservable();

            orchestrator.SyncCompleteObservable.Subscribe(syncOperationCompleted);
            isFrozen = false;
        }
Example #2
0
        public SyncManager(ISyncStateQueue queue, IStateMachineOrchestrator orchestrator)
        {
            Ensure.Argument.IsNotNull(queue, nameof(queue));
            Ensure.Argument.IsNotNull(orchestrator, nameof(orchestrator));

            this.queue        = queue;
            this.orchestrator = orchestrator;

            orchestrator.SyncCompleteObservable.Subscribe(syncOperationCompleted);
        }
Example #3
0
 protected void Reset()
 {
     Queue        = new SyncStateQueue();
     Transitions  = new TransitionHandlerProvider();
     Scheduler    = new TestScheduler();
     StateMachine = new StateMachine(Transitions, Scheduler, Substitute.For <ISubject <Unit> >());
     EntryPoints  = new StateMachineEntryPoints();
     Orchestrator = new StateMachineOrchestrator(StateMachine, EntryPoints);
     SyncManager  = new SyncManager(Queue, Orchestrator);
 }
Example #4
0
            protected void Reset()
            {
                var analyticsService     = Substitute.For <IAnalyticsService>();
                var lastTimeUsageStorage = Substitute.For <ILastTimeUsageStorage>();
                var timeService          = Substitute.For <ITimeService>();

                Queue        = new SyncStateQueue();
                Transitions  = new TransitionHandlerProvider();
                Scheduler    = new TestScheduler();
                StateMachine = new StateMachine(Transitions, Scheduler, Substitute.For <ISubject <Unit> >());
                EntryPoints  = new StateMachineEntryPoints();
                Orchestrator = new StateMachineOrchestrator(StateMachine, EntryPoints);
                SyncManager  = new SyncManager(Queue, Orchestrator, analyticsService, lastTimeUsageStorage, timeService);
            }
Example #5
0
        public SyncManager(ISyncStateQueue queue, IStateMachineOrchestrator orchestrator)
        {
            Ensure.Argument.IsNotNull(queue, nameof(queue));
            Ensure.Argument.IsNotNull(orchestrator, nameof(orchestrator));

            this.queue        = queue;
            this.orchestrator = orchestrator;

            progress           = new BehaviorSubject <SyncProgress>(SyncProgress.Unknown);
            ProgressObservable = progress.AsObservable();

            orchestrator.SyncCompleteObservable.Subscribe(syncOperationCompleted);
            isFrozen = false;
        }
Example #6
0
 public SyncState StartNextQueuedState(IStateMachineOrchestrator orchestrator)
 {
     if (pulledLast)
     {
         startPush(orchestrator);
         return(Push);
     }
     if (pullSyncQueued)
     {
         startPull(orchestrator);
         return(Pull);
     }
     if (pushSyncQueued)
     {
         startPush(orchestrator);
         return(Push);
     }
     startSleep(orchestrator);
     return(Sleep);
 }
Example #7
0
 private static void startSleep(IStateMachineOrchestrator orchestrator)
 {
     orchestrator.GoToSleep();
 }
Example #8
0
 private void startPush(IStateMachineOrchestrator orchestrator)
 {
     pushSyncQueued = false;
     pulledLast     = false;
     orchestrator.StartPushSync();
 }
Example #9
0
 public TheStartNextQueuedStateMethod()
 {
     orchestrator = new OrchestratorMock(orchestratorCalls);
 }