public void ThrowsWhenDatabaseOperationFails() { var state = new UnsyncableEntityState <IThreadSafeTestModel>(dataSource, TestModel.Unsyncable); dataSource .OverwriteIfOriginalDidNotChange(null, null) .ReturnsForAnyArgs(_ => throw new TestException()); Action callingStart = () => state.Start( (new ApiException(request, response, "Test."), new TestModel(1, SyncStatus.SyncNeeded))).SingleAsync().Wait(); callingStart.Should().Throw <TestException>(); }
private Func <TThreadsafeModel, IObservable <ITransition> > tryOverwrite(TThreadsafeModel originalEntity) => serverEntity => dataSource.OverwriteIfOriginalDidNotChange(originalEntity, serverEntity) .SelectMany(results => getCorrectTransitionFromResults(results, originalEntity));
private Func <TModel, IObservable <IEnumerable <IConflictResolutionResult <TThreadsafeModel> > > > tryOverwrite(TModel entity) => updatedEntity => dataSource.OverwriteIfOriginalDidNotChange( convertToThreadsafeModel(entity), convertToThreadsafeModel(updatedEntity));