public async Task History_WithStartBeforeEnd_Throws() { await Assert.ThrowsAsync <AblyException>(() => _channel.Presence.HistoryAsync(new PaginatedRequestParams { Start = Now, End = Now.AddHours(-1) })); }
public async Task WhenErrorCodeIsTokenSpecific_ShouldAutomaticallyTryToRenewTokenIfRequestFails(int errorCode) { //Now = DateTimeOffset.Now; var tokenDetails = new TokenDetails("id") { Expires = Now.AddHours(1) }; //Had to inline the method otherwise the tests intermittently fail. bool firstAttempt = true; var client = GetRestClient(request => { if (request.Url.Contains("/keys")) { return(_returnedDummyTokenDetails.ToJson().ToAblyResponse()); } if (firstAttempt) { firstAttempt = false; throw new AblyException(new ErrorInfo("", errorCode, HttpStatusCode.Unauthorized)); } return(AblyResponse.EmptyResponse.ToTask()); }, opts => opts.TokenDetails = tokenDetails); await client.StatsAsync(); client.AblyAuth.CurrentToken.Expires.Should().BeCloseTo(_returnedDummyTokenDetails.Expires); client.AblyAuth.CurrentToken.ClientId.Should().Be(_returnedDummyTokenDetails.ClientId); }
public void ShouldThrowIfStartIsGreaterThanEnd(int startOffset, int endOffset, QueryDirection direction) { var query = new StatsRequestParams { Start = Now.AddHours(startOffset), End = Now.AddHours(endOffset), Direction = direction }; ThrowsAsync <AblyException>(() => ExecuteStatsQuery(query)); }
public async Task ShouldAcceptStartAndEndDateTimes(int startOffset, int endOffset, QueryDirection direction) { var query = new StatsRequestParams { Start = Now.AddHours(startOffset), End = Now.AddHours(endOffset), Direction = direction }; await ExecuteStatsQuery(query); LastRequest.AssertContainsParameter("start", query.Start.Value.ToUnixTimeInMilliseconds().ToString()); LastRequest.AssertContainsParameter("end", query.End.Value.ToUnixTimeInMilliseconds().ToString()); }
public async Task ShouldSetCorrectHeaders() { var rest = GetRestClient(); var query = new StatsRequestParams { Start = Now.AddHours(-1), End = Now, Direction = QueryDirection.Forwards, Limit = 1000 }; await rest.StatsAsync(query); LastRequest.AssertContainsParameter("start", query.Start.Value.ToUnixTimeInMilliseconds().ToString()); LastRequest.AssertContainsParameter("end", query.End.Value.ToUnixTimeInMilliseconds().ToString()); LastRequest.AssertContainsParameter("direction", query.Direction.ToString().ToLower()); LastRequest.AssertContainsParameter("limit", query.Limit.Value.ToString()); }