Skip to content

Commit 9d1e6ea

Browse files
committed
AllRegistries TestCaseSource
1 parent 379caf7 commit 9d1e6ea

File tree

4 files changed

+168
-235
lines changed

4 files changed

+168
-235
lines changed
Lines changed: 124 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using NUnit.Framework;
6-
7-
namespace UnityNuGet.Tests
8-
{
9-
public class PlatformDefinitionTests
10-
{
11-
[Test]
12-
public void CanFindDefinitions()
13-
{
14-
var platformDefs = PlatformDefinition.CreateAllPlatforms();
15-
16-
// Look-up by OS should return the most general configuration
17-
PlatformDefinition? win = platformDefs.Find(UnityOs.Windows);
18-
Assert.That(win, Is.Not.Null);
19-
Assert.That(win!.Cpu, Is.EqualTo(UnityCpu.AnyCpu));
20-
21-
// Look-up explicit configuration
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using NUnit.Framework;
6+
7+
namespace UnityNuGet.Tests
8+
{
9+
public class PlatformDefinitionTests
10+
{
11+
[Test]
12+
public void CanFindDefinitions()
13+
{
14+
var platformDefs = PlatformDefinition.CreateAllPlatforms();
15+
16+
// Look-up by OS should return the most general configuration
17+
PlatformDefinition? win = platformDefs.Find(UnityOs.Windows);
18+
Assert.That(win, Is.Not.Null);
19+
Assert.That(win!.Cpu, Is.EqualTo(UnityCpu.AnyCpu));
20+
21+
// Look-up explicit configuration
2222
PlatformDefinition? win64 = platformDefs.Find(UnityOs.Windows, UnityCpu.X64);
2323
Assert.Multiple(() =>
2424
{
@@ -29,116 +29,116 @@ public void CanFindDefinitions()
2929
{
3030
Assert.That(win64?.Cpu, Is.EqualTo(UnityCpu.X64));
3131
Assert.That(win.Children, Does.Contain(win64));
32-
});
33-
34-
// Look-up invalid configuration
35-
PlatformDefinition? and = platformDefs.Find(UnityOs.Android, UnityCpu.None);
36-
Assert.That(and, Is.Null);
37-
}
38-
39-
[Test]
40-
public void RemainingPlatforms_NoneVisited()
41-
{
42-
var platformDefs = PlatformDefinition.CreateAllPlatforms();
43-
var visited = new HashSet<PlatformDefinition>();
44-
45-
// If no platform was visited, the remaining platforms should be the (AnyOS, AnyCPU) config.
46-
HashSet<PlatformDefinition> remaining = platformDefs.GetRemainingPlatforms(visited);
32+
});
33+
34+
// Look-up invalid configuration
35+
PlatformDefinition? and = platformDefs.Find(UnityOs.Android, UnityCpu.None);
36+
Assert.That(and, Is.Null);
37+
}
38+
39+
[Test]
40+
public void RemainingPlatforms_NoneVisited()
41+
{
42+
var platformDefs = PlatformDefinition.CreateAllPlatforms();
43+
var visited = new HashSet<PlatformDefinition>();
44+
45+
// If no platform was visited, the remaining platforms should be the (AnyOS, AnyCPU) config.
46+
HashSet<PlatformDefinition> remaining = platformDefs.GetRemainingPlatforms(visited);
4747
Assert.That(remaining, Is.Not.Null);
4848
Assert.Multiple(() =>
4949
{
5050
Assert.That(remaining, Has.Count.EqualTo(1));
5151
Assert.That(platformDefs, Is.EqualTo(remaining.First()));
52-
});
53-
}
54-
55-
[Test]
56-
public void RemainingPlatforms_OneVisited()
57-
{
58-
var platformDefs = PlatformDefinition.CreateAllPlatforms();
59-
60-
foreach (PlatformDefinition child in platformDefs.Children)
61-
{
62-
var visited = new HashSet<PlatformDefinition>() { child };
63-
HashSet<PlatformDefinition> remaining = platformDefs.GetRemainingPlatforms(visited);
64-
65-
// We should get all other children, except the one already visited
66-
Assert.That(remaining.Count + 1, Is.EqualTo(platformDefs.Children.Count));
67-
foreach (PlatformDefinition r in remaining)
52+
});
53+
}
54+
55+
[Test]
56+
public void RemainingPlatforms_OneVisited()
57+
{
58+
var platformDefs = PlatformDefinition.CreateAllPlatforms();
59+
60+
foreach (var child in platformDefs.Children)
61+
{
62+
var visited = new HashSet<PlatformDefinition>() { child };
63+
HashSet<PlatformDefinition> remaining = platformDefs.GetRemainingPlatforms(visited);
64+
65+
// We should get all other children, except the one already visited
66+
Assert.That(remaining.Count + 1, Is.EqualTo(platformDefs.Children.Count));
67+
foreach (PlatformDefinition r in remaining)
6868
{
6969
Assert.Multiple(() =>
7070
{
7171
Assert.That(child, Is.Not.EqualTo(r));
7272
Assert.That(platformDefs.Children, Does.Contain(r));
73-
});
74-
}
75-
}
76-
}
77-
78-
[Test]
79-
public void RemainingPlatforms_LeafVisited()
80-
{
81-
var platformDefs = PlatformDefinition.CreateAllPlatforms();
82-
PlatformDefinition? win64 = platformDefs.Find(UnityOs.Windows, UnityCpu.X64);
83-
var visited = new HashSet<PlatformDefinition>() { win64! };
84-
85-
// The remaining platforms should be all non-windows, as well as all !x64 windows
86-
var expected = platformDefs.Children
87-
.Except([win64!.Parent])
88-
.Concat(
89-
win64.Parent!.Children
90-
.Except([win64]))
91-
.ToHashSet();
92-
HashSet<PlatformDefinition> actual = platformDefs.GetRemainingPlatforms(visited);
93-
Assert.That(expected.SetEquals(actual), Is.True);
94-
}
95-
96-
[TestCase("")]
97-
[TestCase("base")]
98-
public void TestConfigPath_Root(string basePath)
99-
{
100-
var platformDefs = PlatformDefinition.CreateAllPlatforms();
101-
var file = new PlatformFile("a/b/c.dll", platformDefs);
102-
103-
// We don't use extra paths for the (AnyOS, AnyCPU) configuration
104-
string actual = file.GetDestinationPath(basePath);
105-
string expected = Path.Combine(
106-
basePath,
107-
Path.GetFileName(file.SourcePath));
108-
Assert.That(expected, Is.EqualTo(actual));
109-
}
110-
111-
[TestCase("")]
112-
[TestCase("base")]
113-
public void TestConfigPath_OsOnly(string basePath)
114-
{
115-
var platformDefs = PlatformDefinition.CreateAllPlatforms();
116-
PlatformDefinition? win = platformDefs.Find(UnityOs.Windows);
117-
var file = new PlatformFile("a/b/c.dll", win!);
118-
119-
string actual = file.GetDestinationPath(basePath);
120-
string expected = Path.Combine(
121-
basePath,
122-
"Windows",
123-
Path.GetFileName(file.SourcePath));
124-
Assert.That(expected, Is.EqualTo(actual));
125-
}
126-
127-
[TestCase("")]
128-
[TestCase("base")]
129-
public void TestConfigPath_Full(string basePath)
130-
{
131-
var platformDefs = PlatformDefinition.CreateAllPlatforms();
132-
PlatformDefinition? win64 = platformDefs.Find(UnityOs.Windows, UnityCpu.X64);
133-
var file = new PlatformFile("a/b/c.dll", win64!);
134-
135-
string actual = file.GetDestinationPath(basePath);
136-
string expected = Path.Combine(
137-
basePath,
138-
"Windows",
139-
"x86_64",
140-
Path.GetFileName(file.SourcePath));
141-
Assert.That(expected, Is.EqualTo(actual));
142-
}
143-
}
144-
}
73+
});
74+
}
75+
}
76+
}
77+
78+
[Test]
79+
public void RemainingPlatforms_LeafVisited()
80+
{
81+
var platformDefs = PlatformDefinition.CreateAllPlatforms();
82+
PlatformDefinition? win64 = platformDefs.Find(UnityOs.Windows, UnityCpu.X64);
83+
var visited = new HashSet<PlatformDefinition>() { win64! };
84+
85+
// The remaining platforms should be all non-windows, as well as all !x64 windows
86+
var expected = platformDefs.Children
87+
.Except([win64!.Parent])
88+
.Concat(
89+
win64.Parent!.Children
90+
.Except([win64]))
91+
.ToHashSet();
92+
HashSet<PlatformDefinition> actual = platformDefs.GetRemainingPlatforms(visited);
93+
Assert.That(expected.SetEquals(actual), Is.True);
94+
}
95+
96+
[TestCase("")]
97+
[TestCase("base")]
98+
public void TestConfigPath_Root(string basePath)
99+
{
100+
var platformDefs = PlatformDefinition.CreateAllPlatforms();
101+
var file = new PlatformFile("a/b/c.dll", platformDefs);
102+
103+
// We don't use extra paths for the (AnyOS, AnyCPU) configuration
104+
string actual = file.GetDestinationPath(basePath);
105+
string expected = Path.Combine(
106+
basePath,
107+
Path.GetFileName(file.SourcePath));
108+
Assert.That(expected, Is.EqualTo(actual));
109+
}
110+
111+
[TestCase("")]
112+
[TestCase("base")]
113+
public void TestConfigPath_OsOnly(string basePath)
114+
{
115+
var platformDefs = PlatformDefinition.CreateAllPlatforms();
116+
PlatformDefinition? win = platformDefs.Find(UnityOs.Windows);
117+
var file = new PlatformFile("a/b/c.dll", win!);
118+
119+
string actual = file.GetDestinationPath(basePath);
120+
string expected = Path.Combine(
121+
basePath,
122+
"Windows",
123+
Path.GetFileName(file.SourcePath));
124+
Assert.That(expected, Is.EqualTo(actual));
125+
}
126+
127+
[TestCase("")]
128+
[TestCase("base")]
129+
public void TestConfigPath_Full(string basePath)
130+
{
131+
var platformDefs = PlatformDefinition.CreateAllPlatforms();
132+
PlatformDefinition? win64 = platformDefs.Find(UnityOs.Windows, UnityCpu.X64);
133+
var file = new PlatformFile("a/b/c.dll", win64!);
134+
135+
string actual = file.GetDestinationPath(basePath);
136+
string expected = Path.Combine(
137+
basePath,
138+
"Windows",
139+
"x86_64",
140+
Path.GetFileName(file.SourcePath));
141+
Assert.That(expected, Is.EqualTo(actual));
142+
}
143+
}
144+
}

src/UnityNuGet.Tests/RegistryCacheTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace UnityNuGet.Tests
1414
{
1515
public class RegistryCacheTests
1616
{
17-
[Test]
17+
[Test,Order(99)]
1818
public async Task TestBuild()
1919
{
2020
bool errorsTriggered = false;

0 commit comments

Comments
 (0)