41 lines
2.6 KiB
C#
41 lines
2.6 KiB
C#
using System.IO;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using MagnetismHeroes.UnityRuntime.Presentation;
|
|
using NUnit.Framework;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace MagnetismHeroes.Tests
|
|
{
|
|
public sealed class ContentVoiceTests
|
|
{
|
|
[Test] public void EveryLiveHelpPairAndBothActualGhostScriptsHaveOfflinePcmClips()
|
|
{
|
|
var prefab=AssetDatabase.LoadAssetAtPath<GameObject>("Assets/MagnetismHeroes/UnityRuntime/Presentation/Prefabs/GameApp.prefab");
|
|
var clips=new SerializedObject(prefab.GetComponent<VoicePlayer>()).FindProperty("_clips");
|
|
var ids=Enumerable.Range(0,clips.arraySize).Select(i=>clips.GetArrayElementAtIndex(i).FindPropertyRelative("id").stringValue).ToArray();
|
|
Assert.That(ids.Length, Is.EqualTo(44)); Assert.That(ids.Distinct().Count(), Is.EqualTo(44));
|
|
foreach (string id in new[] {"guide_find","guide_uncounted","demo_merge6","demo_split10"}.Concat(
|
|
Enumerable.Range(2,9).SelectMany(size=>Enumerable.Range(1,size/2).Select(count=>$"guide_split_{size}_{count}"))))
|
|
{
|
|
Assert.That(ids, Does.Contain(id));
|
|
int index=System.Array.IndexOf(ids,id); var clip=(AudioClip)clips.GetArrayElementAtIndex(index).FindPropertyRelative("clip").objectReferenceValue;
|
|
Assert.That(clip, Is.Not.Null,id); Assert.That(clip.frequency, Is.EqualTo(44100)); Assert.That(clip.channels, Is.EqualTo(1)); Assert.That(clip.samples, Is.GreaterThan(0));
|
|
var importer=(AudioImporter)AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(clip));
|
|
Assert.That(importer.defaultSampleSettings.compressionFormat, Is.EqualTo(AudioCompressionFormat.PCM));
|
|
Assert.That(importer.defaultSampleSettings.loadType, Is.EqualTo(AudioClipLoadType.DecompressOnLoad));
|
|
}
|
|
Assert.That(ids.Count(id=>id.StartsWith("guide_split_")), Is.EqualTo(25));
|
|
}
|
|
[TestCase("count_01","13A882CE1620140D447635E14F2D4758045D5E348960C17386DF1C720050C100")]
|
|
[TestCase("guide_collect","62E15C9E38C36F4094A6C7E9C5148510141290B5F41DB5AAD9DC1D8F1A158594")]
|
|
[TestCase("guide_count","DEBE29B89F3E2856F2BF4C5E01707A5F0A0657E5768C03BE385EC88FA2328B40")]
|
|
[TestCase("count_08","FA8034948F6AC3E289E8E7E9FB447943760D4ED5AC577C8AB0C961C608FE49C2")]
|
|
public void UserApprovedVoiceBytesRemainExact(string id,string hash)
|
|
{
|
|
using (var sha=SHA256.Create()) Assert.That(System.BitConverter.ToString(sha.ComputeHash(File.ReadAllBytes($"Assets/MagnetismHeroes/UnityRuntime/Presentation/Audio/Voice/{id}.wav"))).Replace("-",""), Is.EqualTo(hash));
|
|
}
|
|
}
|
|
}
|