-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGettingStarted.cs
65 lines (55 loc) · 1.9 KB
/
GettingStarted.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) CBC/Radio-Canada. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LinkIt.Samples.LinkedSources;
using Xunit;
namespace LinkIt.Samples
{
public class GettingStarted: IClassFixture<LoadLinkProtocolFixture>
{
private readonly LoadLinkProtocolFixture _fixture;
public GettingStarted(LoadLinkProtocolFixture fixture)
{
_fixture = fixture;
}
[Fact]
public async Task LoadLink_ById()
{
var actual = await _fixture.LoadLinkProtocol.LoadLink<MediaLinkedSource>().ByIdAsync(1);
Assert.Equal(1, actual.Model.Id);
Assert.Collection(
actual.Tags,
t => Assert.Equal(1001, t.Id),
t => Assert.Equal(1002, t.Id)
);
}
[Fact]
public async Task LoadLink_ByIds()
{
var actual = (await _fixture.LoadLinkProtocol.LoadLink<MediaLinkedSource>().ByIdsAsync(new List<int> { 1, 2, 3 }))
.OrderBy(x => x.Model.Id)
.ToList();
Assert.Equal(3, actual.Count);
Assert.Equal(1, actual[0].Model.Id);
Assert.Collection(
actual[0].Tags,
t => Assert.Equal(1001, t.Id),
t => Assert.Equal(1002, t.Id)
);
Assert.Equal(2, actual[1].Model.Id);
Assert.Collection(
actual[1].Tags,
t => Assert.Equal(1002, t.Id),
t => Assert.Equal(1003, t.Id)
);
Assert.Equal(3, actual[2].Model.Id);
Assert.Collection(
actual[2].Tags,
t => Assert.Equal(1003, t.Id),
t => Assert.Equal(1004, t.Id)
);
}
}
}