public void FireAndForgetReturnsSuccessEvenIfTaskFails() { var mapper = new TelegramBotMapper(new TelegramBotClient(ApiKey), this.responseFactory); var result = mapper.FireAndForgetProxyCall(this.ThrowingTaskAsync()); var successResponse = JsonConvert.DeserializeObject <Response <string> >(result); Assert.True(successResponse.IsSuccess); }
public async Task LongRunningFireAndForgetTaskGetsCancelledAsync() { var mapper = new TelegramBotMapper(new TelegramBotClient(ApiKey), this.responseFactory); var cts = new CancellationTokenSource(3000); var result = mapper.FireAndForgetProxyCall(this.LongRunningTaskAsync(cts.Token)); var successResponse = JsonConvert.DeserializeObject <Response <string> >(result); Assert.True(successResponse.IsSuccess); Assert.False(string.IsNullOrWhiteSpace(successResponse.CorrelationKey)); var messageStoreResult = await this.WaitForMessageStoreAsync(mapper, successResponse.CorrelationKey); var correlatedResponse = JsonConvert.DeserializeObject <Response <Error> >(messageStoreResult); Assert.Equal(typeof(OperationCanceledException).Name, correlatedResponse.Content.ExceptionType); }