-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
MinimalExampleTests.cs
50 lines (40 loc) · 1.72 KB
/
MinimalExampleTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2022 Valters Melnalksnis
// Licensed under the Apache License 2.0.
// See LICENSE file in the project root for full license information.
using System.Linq;
using System.Net.Http;
using System.Net.Mime;
using System.Threading.Tasks;
using NodaTime;
using VMelnalksnis.PaperlessDotNet.Correspondents;
using VMelnalksnis.PaperlessDotNet.Documents;
using VMelnalksnis.PaperlessDotNet.Serialization;
using VMelnalksnis.PaperlessDotNet.Tags;
using VMelnalksnis.PaperlessDotNet.Tasks;
namespace VMelnalksnis.PaperlessDotNet.Tests.Integration;
public sealed class MinimalExampleTests : PaperlessTests
{
private readonly IPaperlessClient _paperlessClient;
public MinimalExampleTests(PaperlessFixture paperlessFixture)
: base(paperlessFixture)
{
var options = paperlessFixture.Options;
var httpClient = new HttpClient { BaseAddress = options.BaseAddress };
httpClient.DefaultRequestHeaders.Add("Accept", $"{MediaTypeNames.Application.Json}; version=2");
httpClient.DefaultRequestHeaders.Authorization = new("Token", options.Token);
var serializerOptions = new PaperlessJsonSerializerOptions(DateTimeZoneProviders.Tzdb);
var taskClient = new TaskClient(httpClient, serializerOptions);
var correspondentClient = new CorrespondentClient(httpClient, serializerOptions);
var documentClient = new DocumentClient(httpClient, serializerOptions, taskClient, options.TaskPollingDelay);
var tagClient = new TagClient(httpClient, serializerOptions);
_paperlessClient = new PaperlessClient(correspondentClient, documentClient, tagClient);
}
[Test]
public async Task ShouldNotThrow()
{
await FluentActions
.Awaiting(() => _paperlessClient.Correspondents.GetAll().ToListAsync().AsTask())
.Should()
.NotThrowAsync();
}
}