Add Geometry Unity EditMode package tests

This commit is contained in:
Meta Vens 2026-07-22 05:17:07 +01:00
commit 4df2c2a42b
7 changed files with 115 additions and 0 deletions

View file

@ -61,6 +61,8 @@ $requiredTemplateFiles = @(
"Runtime\Unity\GameCult.Geometry.Unity.asmdef",
"Runtime\Unity\PlanetaryPatchMeshAdapter.cs",
"Runtime\Unity\PlanetaryPageUpload.cs",
"Tests\Editor\GameCult.Geometry.Tests.Editor.asmdef",
"Tests\Editor\GeometryPackageTests.cs",
"Shaders\AdvancedErosionFilter.hlsl",
"Shaders\GameCult.Geometry.hlsl",
"Shaders\Planetary.hlsl",
@ -85,6 +87,12 @@ if ($missingAssetMetas.Count -ne 0 -or $missingDirectoryMetas.Count -ne 0) {
throw "Tracked Geometry Unity package has assets without stable .meta files: $($missing -join ', ')"
}
$assemblyDirectories = @($unityAssetFiles | Where-Object { $_.Extension -eq ".asmdef" } | Group-Object DirectoryName)
$duplicateAssemblyDirectories = @($assemblyDirectories | Where-Object { $_.Count -ne 1 })
if ($duplicateAssemblyDirectories.Count -ne 0) {
throw "Each Geometry Unity assembly directory must contain exactly one asmdef: $($duplicateAssemblyDirectories.Name -join ', ')"
}
$templateManifest = Get-Content -LiteralPath (Join-Path $templateRoot "package.json") -Raw | ConvertFrom-Json
$expectedFileVersion = "$($templateManifest.version).0"
$trackedAssembly = Join-Path $templatePluginRoot "GameCult.Geometry.dll"

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 97ae3726627d441b8d85e69d4ea804b9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3aa2de1207ba4593a6927bed95bdfea0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,19 @@
{
"name": "GameCult.Geometry.Tests.Editor",
"rootNamespace": "GameCult.Geometry.Tests.Editor",
"references": [
"CultMath",
"GameCult.Geometry",
"GameCult.Geometry.Unity"
],
"includePlatforms": ["Editor"],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false,
"optionalUnityReferences": ["TestAssemblies"]
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 73e8e3a82a3441ec9f2a0f668c90f5b5
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,54 @@
using CultMath;
using GameCult.Geometry.Unity;
using NUnit.Framework;
using UnityEngine;
namespace GameCult.Geometry.Tests.Editor
{
public sealed class GeometryPackageTests
{
[Test]
public void CultMathPrimitivesAreVisible()
{
var value = new float3(2f, 3f, 4f);
Assert.That(value.x, Is.EqualTo(2f));
Assert.That(value.y, Is.EqualTo(3f));
Assert.That(value.z, Is.EqualTo(4f));
}
[Test]
public void CoreGeometryTypesUseCultMathPrimitives()
{
var sphere = new CultSphere(new float3(1f, 2f, 3f), 4f);
Assert.That(sphere.Center, Is.EqualTo(new float3(1f, 2f, 3f)));
Assert.That(sphere.Radius, Is.EqualTo(4f));
Assert.That(sphere.Contains(new float3(1f, 2f, 7f)), Is.True);
}
[Test]
public void PlanetaryAdapterCreatesUnityMesh()
{
var mesh = PlanetaryPatchMeshAdapter.CreateFaceMesh(
PlanetaryCubeFace.PositiveZ,
2,
3f);
try
{
Assert.That(mesh, Is.Not.Null);
Assert.That(mesh.name, Does.Contain("PositiveZ"));
Assert.That(mesh.vertexCount, Is.EqualTo(9));
Assert.That(mesh.normals.Length, Is.EqualTo(9));
Assert.That(mesh.uv.Length, Is.EqualTo(9));
Assert.That(mesh.triangles.Length, Is.EqualTo(24));
Assert.That(mesh.bounds.size.sqrMagnitude, Is.GreaterThan(0f));
}
finally
{
Object.DestroyImmediate(mesh);
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cc0a7b5b20004c72b9c9395d3c73360c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: