Files

78 lines
2.6 KiB
C#

using System;
using System.Reflection;
using BumpCombat.Combat;
using BumpCombat.Player;
using NUnit.Framework;
using UnityEditor;
using UnityEngine;
namespace BumpCombat.Tests
{
public sealed class ArtifactChargeVisualTests
{
private static readonly ActiveArtifactEffect[] Effects =
{
ActiveArtifactEffect.Dash,
ActiveArtifactEffect.Pulse,
ActiveArtifactEffect.Phoenix,
ActiveArtifactEffect.Cyclone,
ActiveArtifactEffect.ThunderCrash,
ActiveArtifactEffect.ChainLightning,
};
[Test]
public void ChargeResources_UseSix64PixelCellsAndPointImport()
{
foreach (ActiveArtifactEffect effect in Effects)
{
foreach (string phase in new[]
{
"Aura",
"ReadyAura",
"Flash",
"Release",
})
{
string path =
$"Assets/_Project/Resources/Artifacts/Charge/"
+ $"{effect}-{phase}-v1.png";
Texture2D texture = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
Assert.That(texture, Is.Not.Null, path);
Assert.That(
texture.width,
Is.EqualTo(phase == "Flash" ? 256 : 384),
path);
Assert.That(texture.height, Is.EqualTo(64), path);
Assert.That(texture.filterMode, Is.EqualTo(FilterMode.Point), path);
Assert.That(texture.mipmapCount, Is.EqualTo(1), path);
}
}
}
[Test]
public void ControllerAwake_AutoAddsChargeVisualComponent()
{
GameObject owner = new("Artifact Charge Visual Harness");
try
{
owner.AddComponent<PlayerStats>();
owner.AddComponent<Rigidbody2D>();
ActiveArtifactController controller =
owner.AddComponent<ActiveArtifactController>();
typeof(ActiveArtifactController)
.GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic)
?.Invoke(controller, null);
Assert.That(
owner.GetComponent<ArtifactChargeVisual>(),
Is.Not.Null);
Assert.That(controller, Is.Not.Null);
}
finally
{
UnityEngine.Object.DestroyImmediate(owner);
}
}
}
}