예제 #1
0
 /// <summary>
 /// Creates an API call from the given async/sync functions.
 /// </summary>
 /// <typeparam name="TRequest">Request type</typeparam>
 /// <typeparam name="TResponse">Response type</typeparam>
 /// <param name="asyncCall">Function to call for async requests</param>
 /// <param name="syncCall">Function to call for sync requests</param>
 /// <param name="baseCallSettings">The default call settings. May be null.</param>
 /// <param name="clock">The clock to use; defaults to a new <see cref="FakeClock"/>.</param>
 /// <returns>The new API call.</returns>
 public static ApiCall <TRequest, TResponse> Create <TRequest, TResponse>(
     Func <TRequest, CallOptions, Task <TResponse> > asyncCall,
     Func <TRequest, CallOptions, TResponse> syncCall,
     CallSettings baseCallSettings = null,
     IClock clock = null)
     where TRequest : class, IMessage <TRequest>
     where TResponse : class, IMessage <TResponse>
 {
     clock = clock ?? new FakeClock();
     return(new ApiCall <TRequest, TResponse>(
                (req, cs) => asyncCall(req, baseCallSettings.MergedWith(cs).ToCallOptions(clock)),
                (req, cs) => syncCall(req, baseCallSettings.MergedWith(cs).ToCallOptions(clock)),
                baseCallSettings));
 }
 public void MergedWith_OneNull()
 {
     CallSettings settings1 = new CallSettings(null, null, null, null, null, null);
     CallSettings settings2 = null;
     Assert.Same(settings1, settings1.MergedWith(settings2));
     Assert.Same(settings1, settings2.MergedWith(settings1));
 }
예제 #3
0
        public void MergedWith_OneNull()
        {
            CallSettings settings1 = new CallSettings(null, null, null, null, null, null);
            CallSettings settings2 = null;

            Assert.Same(settings1, settings1.MergedWith(settings2));
            Assert.Same(settings1, settings2.MergedWith(settings1));
        }
예제 #4
0
 partial void Modify_MutateRowRequest(ref MutateRowRequest request, ref CallSettings settings)
 {
     if (request.IsIdempotent())
     {
         settings = _idempotentMutateRowSettings.MergedWith(settings);
     }
     ApplyResourcePrefixHeader(ref settings, request.TableName);
 }
        public void MergedWith_BothNonNull()
        {
            CallTiming timing1 = CallTiming.FromExpiration(Expiration.None);
            CallTiming timing2 = CallTiming.FromDeadline(DateTime.UtcNow);

            CancellationToken token = new CancellationTokenSource().Token;

            var settings1 = new CallSettings(token, null, timing1, null, null, null);
            var settings2 = new CallSettings(null, null, timing2, null, null, null);
            var merged = settings1.MergedWith(settings2);
            Assert.Equal(token, merged.CancellationToken);
            Assert.Same(timing2, merged.Timing);
        }
예제 #6
0
        public void MergedWith_BothNonNull()
        {
            Expiration expiration1 = Expiration.None;
            Expiration expiration2 = Expiration.FromDeadline(DateTime.UtcNow);

            CancellationToken token = new CancellationTokenSource().Token;

            var settings1 = new CallSettings(token, expiration1, null, null, null, null);
            var settings2 = new CallSettings(null, expiration2, null, null, null, null);
            var merged    = settings1.MergedWith(settings2);

            Assert.Equal(token, merged.CancellationToken);
            Assert.Same(expiration2, merged.Expiration);
        }
예제 #7
0
        public void MergedWith_BothNonNull()
        {
            CallTiming timing1 = CallTiming.FromExpiration(Expiration.None);
            CallTiming timing2 = CallTiming.FromDeadline(DateTime.UtcNow);

            CancellationToken token = new CancellationTokenSource().Token;

            var settings1 = new CallSettings(token, null, timing1, null, null, null);
            var settings2 = new CallSettings(null, null, timing2, null, null, null);
            var merged    = settings1.MergedWith(settings2);

            Assert.Equal(token, merged.CancellationToken);
            Assert.Same(timing2, merged.Timing);
        }
예제 #8
0
        public void MergedWith_BothNull()
        {
            CallSettings settings = null;

            Assert.Null(settings.MergedWith(null));
        }
예제 #9
0
 protected override CallSettings GetEffectiveCallSettingsForGetOperation(CallSettings callSettings)
 => _baseCallSettings.MergedWith(callSettings);