mirror of
https://github.com/Earth-Genesis-Games/Ajedrez_Purgatorio.git
synced 2026-09-11 09:47:35 +00:00
fix: update tests for silent CampaignConfig OnEnable + Linux SaveSystem
This commit is contained in:
@@ -5,8 +5,8 @@ using UnityEngine.TestTools;
|
||||
/// <summary>
|
||||
/// Cobertura de las ramas de error de CampaignConfig.LoadFromJson:
|
||||
/// JSON válido sin capítulos y JSON malformado (excepción de parseo).
|
||||
/// Nota: CreateInstance dispara OnEnable → LoadFromJson sin fuente, que
|
||||
/// loguea Error; por eso el flag de logs se activa antes de instanciar.
|
||||
/// Nota: CreateInstance dispara OnEnable pero es silencioso cuando no
|
||||
/// hay fuente JSON asignada.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
[Category("Unit")]
|
||||
@@ -22,9 +22,8 @@ public class CampaignConfigCoverageTests
|
||||
|
||||
private CampaignConfig CreateUnloadedConfig()
|
||||
{
|
||||
// CreateInstance dispara OnEnable → LoadFromJson sin fuente (Error):
|
||||
// se espera explícitamente porque ignoreFailingMessages en SetUp no persiste.
|
||||
LogAssert.Expect(LogType.Error, "[CampaignConfig] No se asignó archivo JSON de campaña.");
|
||||
// CreateInstance dispara OnEnable → LoadFromJson sin fuente.
|
||||
// OnEnable es silencioso cuando no hay fuente asignada (sin error log).
|
||||
return ScriptableObject.CreateInstance<CampaignConfig>();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,7 @@ namespace AjedrezPurgatorio.Tests.Unit.Campaign
|
||||
|
||||
// Carga el registry desde Resources/Campaigns igual que Awake,
|
||||
// pero sin singleton ni DontDestroyOnLoad (incompatibles con EditMode).
|
||||
// Sin _campaignConfig asignado, LoadFromJson registra un error esperado.
|
||||
LogAssert.Expect(LogType.Error, "[CampaignConfig] No se asignó archivo JSON de campaña.");
|
||||
// OnEnable es silencioso cuando no hay fuente JSON asignada.
|
||||
_buildRegistryMethod.Invoke(_manager, null);
|
||||
}
|
||||
|
||||
@@ -68,8 +67,6 @@ namespace AjedrezPurgatorio.Tests.Unit.Campaign
|
||||
int countAfterFirstBuild = _manager.CampaignCount;
|
||||
|
||||
// BuildCampaignRegistry limpia y reconstruye; los duplicados se descartan.
|
||||
// El rebuild repite el log de config sin JSON (el Expect del SetUp ya se consumió).
|
||||
LogAssert.Expect(LogType.Error, "[CampaignConfig] No se asignó archivo JSON de campaña.");
|
||||
_buildRegistryMethod.Invoke(_manager, null);
|
||||
|
||||
Assert.AreEqual(countAfterFirstBuild, _manager.CampaignCount,
|
||||
|
||||
@@ -70,8 +70,8 @@ public class CampaignManagerCoverageTests
|
||||
|
||||
private CampaignConfig MakeConfigFromJson(string json)
|
||||
{
|
||||
// CreateInstance dispara OnEnable → LoadFromJson sin fuente (Error esperado).
|
||||
LogAssert.Expect(LogType.Error, "[CampaignConfig] No se asignó archivo JSON de campaña.");
|
||||
// CreateInstance dispara OnEnable → LoadFromJson sin fuente.
|
||||
// OnEnable es silencioso cuando no hay fuente JSON asignada.
|
||||
var config = ScriptableObject.CreateInstance<CampaignConfig>();
|
||||
config.SetJsonSource(new TextAsset(json));
|
||||
config.LoadFromJson();
|
||||
@@ -96,8 +96,8 @@ public class CampaignManagerCoverageTests
|
||||
typeof(CampaignManager).GetField("_campaignConfig", Flags)
|
||||
.SetValue(_manager, inspectorConfig);
|
||||
|
||||
// La config del Inspector se añade SIN log (línea 165-166); los
|
||||
// recursos de Resources sí emiten Error (OnEnable) + Log (registro).
|
||||
// La config del Inspector se añade SIN log; los recursos de
|
||||
// Resources se registran al BuildCampaignRegistry (OnEnable silencioso).
|
||||
LogAssert.ignoreFailingMessages = true;
|
||||
InvokePrivate("BuildCampaignRegistry");
|
||||
LogAssert.ignoreFailingMessages = false;
|
||||
|
||||
@@ -293,7 +293,19 @@ namespace AjedrezPurgatorio.Tests.Unit.Meta
|
||||
{
|
||||
LogAssert.ignoreFailingMessages = false;
|
||||
}
|
||||
Assert.IsFalse(result, "Borrar un archivo bloqueado debe fallar controlado.");
|
||||
|
||||
// Linux file locking is advisory — File.Delete may succeed.
|
||||
if (Application.platform == RuntimePlatform.LinuxEditor ||
|
||||
Application.platform == RuntimePlatform.LinuxPlayer)
|
||||
{
|
||||
Assert.IsTrue(result,
|
||||
"Linux: File.Delete succeeds despite FileShare.None (advisory locking).");
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsFalse(result,
|
||||
"Windows: Borrar un archivo bloqueado debe fallar controlado.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user