-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Expand file tree
/
Copy pathRidTests.cs
More file actions
66 lines (54 loc) · 3.3 KB
/
RidTests.cs
File metadata and controls
66 lines (54 loc) · 3.3 KB
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 System.Collections.Generic;
using Xunit;
namespace Microsoft.NETCore.Platforms.BuildTasks.Tests
{
public class RidTests
{
public static IEnumerable<object[]> ValidRIDData()
{
yield return new object[] { "win10-x64", new RID() { BaseRID = "win", OmitVersionDelimiter = true, Version = new RuntimeVersion("10"), Architecture = "x64" }, null };
yield return new object[] { "win10", new RID() { BaseRID = "win", OmitVersionDelimiter = true, Version = new RuntimeVersion("10")}, null };
yield return new object[] { "linux", new RID() { BaseRID = "linux" }, null };
yield return new object[] { "linux-x64", new RID() { BaseRID = "linux", Architecture = "x64" }, null };
yield return new object[] { "linux-x64", new RID() { BaseRID = "linux", Architecture = "x64" }, null };
yield return new object[] { "debian.10-x64", new RID() { BaseRID = "debian", Version = new RuntimeVersion("10"), Architecture = "x64" }, null };
yield return new object[] { "linuxmint.19.2-x64", new RID() { BaseRID = "linuxmint", Version = new RuntimeVersion("19.2"), Architecture = "x64" }, null };
yield return new object[] { "ubuntu.14.04-x64", new RID() { BaseRID = "ubuntu", Version = new RuntimeVersion("14.04"), Architecture = "x64" }, null };
yield return new object[] { "foo-bar.42-arm", new RID() { BaseRID = "foo-bar", Version = new RuntimeVersion("42"), Architecture = "arm" }, null };
yield return new object[] { "foo-bar-arm", new RID() { BaseRID = "foo", Architecture = "bar", Qualifier = "arm" }, // demonstrates ambiguity, avoid using `-` in base
new RID() { BaseRID = "foo-bar", Architecture = "arm" } };
yield return new object[] { "linux-musl-x64", new RID() { BaseRID = "linux", Architecture = "musl", Qualifier = "x64" }, // yes, we already have ambiguous RIDs
new RID() { BaseRID = "linux-musl", Architecture = "x64" } };
}
[Theory]
[MemberData(nameof(ValidRIDData))]
internal void ParseCorrectly(string input, RID expected, RID? expectedNoQualifier)
{
_ = expectedNoQualifier; // unused
RID actual = RID.Parse(input, noQualifier: false);
Assert.Equal(expected, actual);
}
[Theory]
[MemberData(nameof(ValidRIDData))]
internal void ParseCorrectlyNoQualifier(string input, RID expected, RID? expectedNoQualifier)
{
expectedNoQualifier ??= expected;
RID actual = RID.Parse(input, noQualifier: true);
Assert.Equal(expectedNoQualifier, actual);
}
[Theory]
[MemberData(nameof(ValidRIDData))]
internal void ToStringAsExpected(string expected, RID rid, RID? expectedNoQualifierRid)
{
string actual = rid.ToString();
Assert.Equal(expected, actual);
if (expectedNoQualifierRid is not null)
{
actual = expectedNoQualifierRid.ToString();
Assert.Equal(expected, actual);
}
}
}
}