feat(launcher): Campaign LA add Avalonia desktop shell
This commit is contained in:
parent
6c4cd2bbc6
commit
d0a9c65d85
31 changed files with 4831 additions and 16 deletions
77
tests/AcDream.Launcher.Tests/LauncherProjectBoundaryTests.cs
Normal file
77
tests/AcDream.Launcher.Tests/LauncherProjectBoundaryTests.cs
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
using System.Xml.Linq;
|
||||
|
||||
namespace AcDream.Launcher.Tests;
|
||||
|
||||
public sealed class LauncherProjectBoundaryTests
|
||||
{
|
||||
private static readonly string[] ExpectedAvaloniaPackages =
|
||||
[
|
||||
"Avalonia",
|
||||
"Avalonia.Desktop",
|
||||
"Avalonia.Themes.Fluent",
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void LauncherReferencesOnlyLauncherCoreAndPinsOneAvaloniaVersion()
|
||||
{
|
||||
string root = FindRepositoryRoot();
|
||||
string projectPath = Path.Combine(
|
||||
root,
|
||||
"src",
|
||||
"AcDream.Launcher",
|
||||
"AcDream.Launcher.csproj");
|
||||
XDocument project = XDocument.Load(projectPath);
|
||||
|
||||
string projectReference = Assert.Single(
|
||||
project.Descendants("ProjectReference")
|
||||
.Select(element => element.Attribute("Include")?.Value ?? string.Empty));
|
||||
Assert.EndsWith(
|
||||
"AcDream.Launcher.Core\\AcDream.Launcher.Core.csproj",
|
||||
projectReference,
|
||||
StringComparison.Ordinal);
|
||||
|
||||
(string Name, string Version)[] packages = project
|
||||
.Descendants("PackageReference")
|
||||
.Select(element => (
|
||||
element.Attribute("Include")?.Value ?? string.Empty,
|
||||
element.Attribute("Version")?.Value ?? string.Empty))
|
||||
.OrderBy(package => package.Item1, StringComparer.Ordinal)
|
||||
.ToArray();
|
||||
|
||||
Assert.Equal(ExpectedAvaloniaPackages, packages.Select(package => package.Name));
|
||||
Assert.All(packages, package => Assert.Equal("12.1.1", package.Version));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LauncherAndItsTestsAreSolutionMembers()
|
||||
{
|
||||
string root = FindRepositoryRoot();
|
||||
XDocument solution = XDocument.Load(Path.Combine(root, "AcDream.slnx"));
|
||||
string[] paths = solution.Descendants("Project")
|
||||
.Select(element => (element.Attribute("Path")?.Value ?? string.Empty)
|
||||
.Replace('\\', '/'))
|
||||
.ToArray();
|
||||
|
||||
Assert.Contains("src/AcDream.Launcher/AcDream.Launcher.csproj", paths);
|
||||
Assert.Contains("tests/AcDream.Launcher.Tests/AcDream.Launcher.Tests.csproj", paths);
|
||||
}
|
||||
|
||||
private static string FindRepositoryRoot()
|
||||
{
|
||||
foreach (string start in new[] { AppContext.BaseDirectory, Environment.CurrentDirectory })
|
||||
{
|
||||
DirectoryInfo? directory = new(start);
|
||||
while (directory is not null)
|
||||
{
|
||||
if (File.Exists(Path.Combine(directory.FullName, "AcDream.slnx")))
|
||||
{
|
||||
return directory.FullName;
|
||||
}
|
||||
|
||||
directory = directory.Parent;
|
||||
}
|
||||
}
|
||||
|
||||
throw new DirectoryNotFoundException("Could not find AcDream.slnx.");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue