public async Task Call_ValidateUnsuccessfulResponse() { var handler = new TestHttpClientHandler(); var httpInteractor = new DaprHttpInteractor(handler); var actorType = "ActorType_Test"; var actorId = "ActorId_Test"; var timerName = "TimerName"; var task = httpInteractor.UnregisterTimerAsync(actorType, actorId, timerName); handler.Requests.TryDequeue(out var entry).Should().BeTrue(); var error = new DaprError() { ErrorCode = "ERR_STATE_STORE", Message = "State Store Error" }; var message = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(JsonSerializer.Serialize(error)) }; entry.Completion.SetResult(message); await FluentActions.Awaiting(async() => await task).Should().ThrowAsync <DaprApiException>(); }
public async Task Call_ValidateUnsuccessfulResponse() { await using var client = TestClient.CreateForDaprHttpInterator(); var actorType = "ActorType_Test"; var actorId = "ActorId_Test"; var timerName = "TimerName"; var request = await client.CaptureHttpRequestAsync(async httpInteractor => { await httpInteractor.UnregisterTimerAsync(actorType, actorId, timerName); }); request.Dismiss(); var error = new DaprError() { ErrorCode = "ERR_STATE_STORE", Message = "State Store Error" }; var message = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(JsonSerializer.Serialize(error)) }; await Assert.ThrowsAsync <DaprApiException>(async() => { await request.CompleteAsync(message); }); }