补齐 package Tests 第一刀

This commit is contained in:
JSD\13999
2026-06-06 16:14:17 +08:00
parent 0930e7c173
commit 7b2243a40b
13 changed files with 334 additions and 169 deletions

View File

@@ -1,8 +1,13 @@
# Changelog
## Unreleased
- Added `Samples~/MainMenuP0` package sample metadata and content.
- Added the first `Tests~/EditMode` package smoke test slice.
- Updated package installation and layout documentation to reflect the current P2 package state.
## 0.2.0-preview.1
- Added the first Git-consumable FlowScope Game Core package layout.
- Mirrored Runtime, Addressables, and Editor sources from `Assets/FlowScope`.
- Added package metadata and Git installation notes for consuming Unity projects.

View File

@@ -35,5 +35,6 @@ Add the package to the consuming project's `Packages/manifest.json`:
- `FlowScope.Addressables` references `FlowScope.Runtime`, `Unity.Addressables`, and `Unity.ResourceManager`.
- `FlowScope.Editor` is Editor-only and only provides read-only diagnostics.
- `Samples~/MainMenuP0` is a package sample candidate mirrored from the project-internal MainMenuP0 sample.
- `Tests~/EditMode` contains the first package-level smoke tests.
Runtime must not depend on Addressables, Editor, Samples, or Tests.

View File

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

View File

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

View File

@@ -0,0 +1,26 @@
{
"name": "FlowScope.PackageTests.EditMode",
"rootNamespace": "FlowScope.PackageTests.EditMode",
"references": [
"FlowScope.Runtime",
"FlowScope.Addressables",
"R3.Unity"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"R3.dll",
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": [],
"optionalUnityReferences": [
"TestAssemblies"
],
"noEngineReferences": false
}

View File

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

View File

@@ -0,0 +1,70 @@
using System.Threading;
using System.Threading.Tasks;
using FlowScope.Addressables;
using FlowScope.Container;
using FlowScope.Resources;
using NUnit.Framework;
namespace FlowScope.PackageTests.EditMode
{
public sealed class PackageSmokeTests
{
[Test]
public void PackageAssemblies_CanBeReferencedFromPackageTests()
{
var container = new Container();
var backend = new AddressablesResourceBackend();
IResourceService resources = new ResourceService(new ImmediateBackend());
container.RegisterInstance(resources);
Assert.AreEqual("Addressables", backend.Name);
Assert.AreSame(resources, container.Resolve<IResourceService>());
container.Dispose();
}
[Test]
public void ResourceService_LoadAsync_CanRunInsidePackageTestAssembly()
{
var backend = new ImmediateBackend();
var service = new ResourceService(backend);
using var handle = service
.LoadAsync<TestAsset>("package-smoke", CancellationToken.None)
.GetAwaiter()
.GetResult();
Assert.That(handle.Asset, Is.Not.Null);
Assert.AreEqual(1, backend.LoadCalls);
handle.Dispose();
Assert.AreEqual(1, backend.ReleaseCalls);
}
private sealed class ImmediateBackend : IResourceBackend
{
public string Name => "Immediate";
public int LoadCalls { get; private set; }
public int ReleaseCalls { get; private set; }
public Task<T> LoadAsync<T>(string key, CancellationToken cancellationToken)
where T : class
{
LoadCalls++;
return Task.FromResult(new TestAsset() as T);
}
public void Release<T>(string key, T asset)
where T : class
{
ReleaseCalls++;
}
}
private sealed class TestAsset
{
}
}
}

View File

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

View File

@@ -0,0 +1,22 @@
# FlowScope Package Tests
This directory contains the first package-level test slice for FlowScope Game Core.
The current tests are intentionally small. They prove that a package test assembly can reference:
- `FlowScope.Runtime`
- `FlowScope.Addressables`
- Unity Test Framework / NUnit
The full development test suite still lives under `My project/Assets/FlowScope/Tests` during P2 migration. Real Addressables fixture validation also remains in the development project because Addressables settings are project-level assets.
## Current Scope
- `EditMode/PackageSmokeTests.cs`
## Not Migrated Yet
- Full Runtime EditMode tests.
- Full PlayMode tests.
- MainMenuP0 sample tests.
- Real Addressables fixture tests.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0b532bf970be439aab8ef4bc3eb5cf2c
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: