private AblyRealtime GetRealtime(Action <ClientOptions> optionsAction = null) { return(GetRealtimeClient(request => { if (request.Url == Defaults.InternetCheckUrl) { return (_internetCheckOK ? Defaults.InternetCheckOkMessage : "Blah").ToAblyResponse(); } return DefaultResponse.ToTask(); }, optionsAction)); }
internal AblyRest GetRestClient(Func <AblyRequest, Task <AblyResponse> > handleRequestFunc, ClientOptions options, IMobileDevice mobileDevice = null) { var client = new AblyRest(options, mobileDevice); client.ExecuteHttpRequest = request => { Requests.Add(request); if (handleRequestFunc != null) { return(handleRequestFunc(request)); } return(DefaultResponse.ToTask()); }; return(client); }
public async Task WithDefaultHostAndRecoverableError_WhenInternetDown_GoesStraightToFailed() { var client = GetConnectedClient(null, request => { if (request.Url == Defaults.InternetCheckUrl) { return("no".ToAblyResponse()); } return(DefaultResponse.ToTask()); }); client.Options.SkipInternetCheck = false; await client.FakeProtocolMessageReceived(new ProtocolMessage(ProtocolMessage.MessageAction.Error) { Error = new ErrorInfo() { StatusCode = HttpStatusCode.GatewayTimeout } }); client.Connection.State.Should().Be(ConnectionState.Failed); }
internal AblyRealtime GetRealtimeClient(Func <AblyRequest, Task <AblyResponse> > handleRequestFunc = null, Action <ClientOptions> setOptionsAction = null) { var options = new ClientOptions(ValidKey) { UseBinaryProtocol = false }; setOptionsAction?.Invoke(options); var client = new AblyRealtime(options); client.RestClient.ExecuteHttpRequest = request => { Requests.Add(request); if (handleRequestFunc != null) { return(handleRequestFunc(request)); } return(DefaultResponse.ToTask()); }; return(client); }