Exemplo n.º 1
0
            public void EmitsFailedWhenAKnownClientErrorExceptionIsReported(ClientErrorException exception)
            {
                SyncProgress?emitted = null;

                SyncManager.ProgressObservable.Subscribe(progress => emitted = progress, (Exception e) => { });

                OrchestratorSyncComplete.OnNext(new Error(exception));

                emitted.Should().NotBeNull();
                emitted.Should().Be(SyncProgress.Failed);
            }
Exemplo n.º 2
0
            public void ReportsTheErrorWhenAKnownClientErrorExceptionIsReported(ClientErrorException exception)
            {
                Exception caughtException = null;

                SyncManager.Errors.Subscribe(e => caughtException = e);

                OrchestratorSyncComplete.OnNext(new Error(exception));

                caughtException.Should().NotBeNull();
                caughtException.Should().Be(exception);
            }
Exemplo n.º 3
0
            public void ReturnsFailedTransitionWhenHttpFailsWithClientErrorException(ClientErrorException exception)
            {
                var state       = CreateState(repository, sinceParameterRepository);
                var observables = createFetchObservablesWhichThrow(exception);

                var transition = state.Start(observables).SingleAsync().Wait();
                var reason     = ((Transition <Exception>)transition).Parameter;

                transition.Result.Should().Be(state.Failed);
                reason.Should().BeAssignableTo <ClientErrorException>();
            }
Exemplo n.º 4
0
        public void ReturnsTheClientErrorTransitionWhenHttpFailsWithClientError(ClientErrorException exception)
        {
            var state  = (UpdateEntityState <ITestModel, IThreadSafeTestModel>)CreateState();
            var entity = new TestModel(1, SyncStatus.InSync);

            api.Update(Arg.Any <ITestModel>()).ReturnsThrowingTaskOf(exception);

            var transition = state.Start(entity).SingleAsync().Wait();
            var parameter  = ((Transition <(Exception Reason, IThreadSafeTestModel)>)transition).Parameter;

            transition.Result.Should().Be(state.ClientError);
            parameter.Reason.Should().BeAssignableTo <ClientErrorException>();
        }
Exemplo n.º 5
0
            public void ReturnsTheClientErrorTransitionWhenHttpFailsWithClientError(ClientErrorException exception)
            {
                var state  = createUpdateState(api, repository);
                var entity = CreateDirtyEntity(1);

                GetUpdateFunction(api)(Arg.Any <TModel>())
                .Returns(_ => Observable.Throw <TApiModel>(exception));

                var transition = state.Start(entity).SingleAsync().Wait();
                var parameter  = ((Transition <(Exception Reason, TModel)>)transition).Parameter;

                transition.Result.Should().Be(state.ClientError);
                parameter.Reason.Should().BeAssignableTo <ClientErrorException>();
            }
Exemplo n.º 6
0
        public void ReturnsClientErrorTransitionWhenHttpFailsWithClientErrorException(ClientErrorException exception)
        {
            var state  = CreateState();
            var entity = new TestModel(-1, SyncStatus.SyncNeeded);

            PrepareApiCallFunctionToThrow(exception);

            var transition = state.Start(entity).SingleAsync().Wait();
            var parameter  = ((Transition <(Exception Reason, IThreadSafeTestModel)>)transition).Parameter;

            transition.Result.Should().Be(state.ClientError);
            parameter.Reason.Should().BeAssignableTo <ClientErrorException>();
        }
Exemplo n.º 7
0
        public void ReturnsClientErrorTransitionWhenHttpFailsWithClientErrorException(ClientErrorException exception)
        {
            var state  = CreateState(api, repository);
            var entity = CreateDirtyEntityWithNegativeId();

            PrepareApiCallFunctionToThrow(exception);

            var transition = state.Start(entity).SingleAsync().Wait();
            var parameter  = ((Transition <(Exception Reason, TModel)>)transition).Parameter;

            transition.Result.Should().Be(state.ClientError);
            parameter.Reason.Should().BeAssignableTo <ClientErrorException>();
        }
Exemplo n.º 8
0
            public void FreezesTheSyncManagerWhenAKnownClientErrorExceptionIsReported(ClientErrorException exception)
            {
                OrchestratorSyncComplete.OnNext(new Error(exception));

                Orchestrator.Received().Freeze();
            }
Exemplo n.º 9
0
 public void ReturnsTheClientErrorTransitionWhenHttpFailsWithClientError(ClientErrorException exception)
 => helper.ReturnsTheClientErrorTransitionWhenHttpFailsWithClientError(exception);
Exemplo n.º 10
0
 public void ReturnsClientErrorTransitionWhenHttpFailsWithClientErrorException(ClientErrorException exception)
 => testHelper.ReturnsFailedTransitionWhenHttpFailsWithClientErrorException(exception);
        public void ReturnsClientErrorTransitionWhenHttpFailsWithClientErrorException(ClientErrorException exception)
        {
            internalState.Start(Arg.Any <IFetchObservables>()).Returns(Observable.Throw <ITransition>(exception));

            var transition = state.Start(fetchObservables).SingleAsync().Wait();
            var reason     = ((Transition <Exception>)transition).Parameter;

            transition.Result.Should().Be(state.Failed);
            reason.Should().BeAssignableTo <ClientErrorException>();
        }
        public void ReturnsClientErrorTransitionWhenHttpFailsWithClientErrorException(ClientErrorException exception)
        {
            var transition = state.Start(exception).SingleAsync().Wait();
            var reason     = ((Transition <ApiException>)transition).Parameter;

            transition.Result.Should().Be(state.Retry);
            reason.Should().BeAssignableTo <ClientErrorException>();
        }