Skip to content

Commit 1f852d5

Browse files
committed
Address CodeRabbit review feedback
1 parent 2c691cf commit 1f852d5

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

examples/LibreOfficeOptions/Program.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
static async Task<string> ConvertWithLibreOfficeOptions(string sourceDirectory, string destinationDirectory, GotenbergSharpClientOptions options)
2424
{
25-
using var handler = new HttpClientHandler();
26-
using var authHandler = !string.IsNullOrWhiteSpace(options.BasicAuthUsername) && !string.IsNullOrWhiteSpace(options.BasicAuthPassword)
27-
? new BasicAuthHandler(options.BasicAuthUsername, options.BasicAuthPassword) { InnerHandler = handler }
28-
: null;
25+
var handler = new HttpClientHandler();
26+
HttpMessageHandler effectiveHandler = handler;
27+
if (!string.IsNullOrWhiteSpace(options.BasicAuthUsername) && !string.IsNullOrWhiteSpace(options.BasicAuthPassword))
28+
effectiveHandler = new BasicAuthHandler(options.BasicAuthUsername, options.BasicAuthPassword) { InnerHandler = handler };
2929

30-
using var httpClient = new HttpClient(authHandler ?? (HttpMessageHandler)handler)
30+
using var httpClient = new HttpClient(effectiveHandler, disposeHandler: true)
3131
{
3232
BaseAddress = options.ServiceUrl,
3333
Timeout = options.TimeOut

test/GotenbergSharpClient.Tests/LibreOfficeOptionsTests.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void SetLibreOfficeOptions_InvalidResolution_Throws()
191191
#region Serialization Tests
192192

193193
[Test]
194-
public void LibreOfficeOptions_SerializesAllSetFields()
194+
public async Task LibreOfficeOptions_SerializesAllSetFields()
195195
{
196196
var options = new LibreOfficeOptions
197197
{
@@ -205,15 +205,15 @@ public void LibreOfficeOptions_SerializesAllSetFields()
205205

206206
httpContents.FirstOrDefault(c =>
207207
c.Headers.ContentDisposition?.Name == "singlePageSheets").Should().NotBeNull();
208-
httpContents.FirstOrDefault(c =>
208+
(await httpContents.FirstOrDefault(c =>
209209
c.Headers.ContentDisposition?.Name == "quality")!
210-
.ReadAsStringAsync().Result.Should().Be("75");
211-
httpContents.FirstOrDefault(c =>
210+
.ReadAsStringAsync()).Should().Be("75");
211+
(await httpContents.FirstOrDefault(c =>
212212
c.Headers.ContentDisposition?.Name == "maxImageResolution")!
213-
.ReadAsStringAsync().Result.Should().Be("300");
214-
httpContents.FirstOrDefault(c =>
213+
.ReadAsStringAsync()).Should().Be("300");
214+
(await httpContents.FirstOrDefault(c =>
215215
c.Headers.ContentDisposition?.Name == "nativeWatermarkText")!
216-
.ReadAsStringAsync().Result.Should().Be("DRAFT");
216+
.ReadAsStringAsync()).Should().Be("DRAFT");
217217
}
218218

219219
[Test]
@@ -230,6 +230,7 @@ public void LibreOfficeOptions_NullFields_NotIncluded()
230230

231231
#region Integration Tests
232232

233+
[Category("Integration")]
233234
[Test]
234235
public async Task MergeOfficeDocs_WithLibreOfficeOptions_Succeeds()
235236
{

0 commit comments

Comments
 (0)