-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathWorkloadResolverTests.cs
66 lines (53 loc) · 2.97 KB
/
WorkloadResolverTests.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
66
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using ManifestReaderTests;
namespace Microsoft.NET.Sdk.WorkloadManifestReader.Tests
{
public class WorkloadResolverTests : SdkTest
{
private const string fakeRootPath = "fakeRootPath";
public WorkloadResolverTests(ITestOutputHelper log) : base(log)
{
}
[Fact]
public void GetExtendedWorkloads_SampleDeduplicatedClosureExpected()
{
var manifestPath = Path.Combine(_testAssetsManager.GetAndValidateTestProjectDirectory("SampleManifest"), "Sample.json");
var workloadResolver = WorkloadResolver.CreateForTests(new FakeManifestProvider(manifestPath), fakeRootPath);
var resultWorkloads = workloadResolver.GetExtendedWorkloads(new List<WorkloadId>()
{
new WorkloadId("xamarin-android-build-x86"),
new WorkloadId("xamarin-empty-mock"),
new WorkloadId("xamarin-android"),
}).ToList();
List<WorkloadResolver.WorkloadInfo> expected = new()
{
new(new WorkloadId("xamarin-android-build-x86"), null),
new(new WorkloadId("xamarin-android-build"), "Build and run Android apps"),
new(new WorkloadId("xamarin-empty-mock"), "Empty mock workload for testing"),
new(new WorkloadId("xamarin-android"), "Create, build and run Android apps"),
new(new WorkloadId("xamarin-android-build-armv7a"), null),
};
resultWorkloads.Should().Equal(expected,
(w1, w2) => w1.Id.Equals(w2.Id) && string.Equals(w1.Description, w2.Description),
"WorkloadResolver should return expected workload infos based on manifest");
}
[Fact]
public void GetExtendedWorkloads_EmptyInputYieldsEmptyOutput()
{
var manifestPath = Path.Combine(_testAssetsManager.GetAndValidateTestProjectDirectory("SampleManifest"), "Sample.json");
var workloadResolver = WorkloadResolver.CreateForTests(new FakeManifestProvider(manifestPath), fakeRootPath);
var resultWorkloads = workloadResolver.GetExtendedWorkloads(Enumerable.Empty<WorkloadId>()).ToList();
resultWorkloads.Should().BeEmpty();
}
[Fact]
public void GetExtendedWorkloads_ThrowsOnUnknownWorkload()
{
var manifestPath = Path.Combine(_testAssetsManager.GetAndValidateTestProjectDirectory("SampleManifest"), "Sample.json");
var workloadResolver = WorkloadResolver.CreateForTests(new FakeManifestProvider(manifestPath), fakeRootPath);
Exception exc = Assert.Throws<WorkloadManifestCompositionException>(() =>
workloadResolver.GetExtendedWorkloads(new List<WorkloadId>() { new WorkloadId("BAH"), }).ToList());
exc.Message.Should().StartWith("Could not find workload 'BAH'");
}
}
}