fix: 垃圾测试
This commit is contained in:
@@ -1,128 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using AibisDream.EditorTools.Localization;
|
||||
using AibisDream.UI;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace AibisDream.SystemEditor.Tests
|
||||
{
|
||||
public sealed class LocalizedObjSpriteTests
|
||||
{
|
||||
private string temporaryRoot;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
temporaryRoot = Path.Combine(
|
||||
Path.GetTempPath(),
|
||||
"AibisDreamLocalizedObjSpriteTests",
|
||||
Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(temporaryRoot);
|
||||
Directory.CreateDirectory(Path.Combine(
|
||||
temporaryRoot,
|
||||
LocalizedObjSpriteValidator.DefaultFolderName));
|
||||
foreach (LocalizedObjSpriteDirectory directory in
|
||||
LocalizedObjSpriteValidator.LocaleDirectories)
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(
|
||||
temporaryRoot,
|
||||
directory.FolderName));
|
||||
}
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(temporaryRoot) && Directory.Exists(temporaryRoot))
|
||||
Directory.Delete(temporaryRoot, true);
|
||||
}
|
||||
|
||||
[TestCase("zh-Hans", "Sprite/Obj/病历.png")]
|
||||
[TestCase("zh-CN", "Sprite/Obj/病历.png")]
|
||||
[TestCase("en", "Sprite/Obj_en/病历.png")]
|
||||
[TestCase("en-US", "Sprite/Obj_en/病历.png")]
|
||||
[TestCase("ja-JP", "Sprite/Obj_ja-JP/病历.png")]
|
||||
[TestCase("ru-RU", "Sprite/Obj_ru/病历.png")]
|
||||
[TestCase("es-ES", "Sprite/Obj_es/病历.png")]
|
||||
[TestCase("pt-BR", "Sprite/Obj_pt-BR/病历.png")]
|
||||
public void GetKey_UsesCanonicalLocaleDirectory(
|
||||
string localeCode,
|
||||
string expected)
|
||||
{
|
||||
Assert.That(
|
||||
LocalizedObjSpriteNaming.GetKey("病历.png", localeCode),
|
||||
Is.EqualTo(expected));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CandidateNames_FallBackToUnsuffixedChineseWithoutDuplicates()
|
||||
{
|
||||
Assert.That(
|
||||
LocalizedObjSpriteNaming.GetCandidateKeys("病历.png", "en"),
|
||||
Is.EqualTo(new[]
|
||||
{
|
||||
"Sprite/Obj_en/病历.png",
|
||||
"Sprite/Obj/病历.png"
|
||||
}));
|
||||
Assert.That(
|
||||
LocalizedObjSpriteNaming.GetCandidateKeys("病历.png", "zh-Hans"),
|
||||
Is.EqualTo(new[] { "Sprite/Obj/病历.png" }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Validator_IgnoresUnsuffixedOnlySprites()
|
||||
{
|
||||
WriteSprite(
|
||||
LocalizedObjSpriteValidator.DefaultFolderName,
|
||||
"普通图片.png");
|
||||
|
||||
Assert.That(
|
||||
LocalizedObjSpriteValidator.Validate(temporaryRoot, false),
|
||||
Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Validator_RequiresEveryVariantAfterAGroupIsDetected()
|
||||
{
|
||||
WriteCompleteGroup("病历");
|
||||
Assert.That(
|
||||
LocalizedObjSpriteValidator.Validate(temporaryRoot, false),
|
||||
Is.Empty);
|
||||
|
||||
File.Delete(Path.Combine(temporaryRoot, "Obj_ru", "病历.png"));
|
||||
var issues = LocalizedObjSpriteValidator.Validate(temporaryRoot, false);
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().AssetPath, Does.EndWith("Obj_ru/病历.png"));
|
||||
Assert.That(issues.Single().Message, Does.Contain("'ru'"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ProjectLocaleFolders_AreAddressableByConvention()
|
||||
{
|
||||
Assert.That(
|
||||
LocalizedObjSpriteValidator.Validate(),
|
||||
Is.Empty);
|
||||
}
|
||||
|
||||
private void WriteCompleteGroup(string logicalName)
|
||||
{
|
||||
WriteSprite(
|
||||
LocalizedObjSpriteValidator.DefaultFolderName,
|
||||
$"{logicalName}.png");
|
||||
foreach (LocalizedObjSpriteDirectory directory in
|
||||
LocalizedObjSpriteValidator.LocaleDirectories)
|
||||
{
|
||||
WriteSprite(directory.FolderName, $"{logicalName}.png");
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteSprite(string folderName, string relativePath)
|
||||
{
|
||||
string filePath = Path.Combine(temporaryRoot, folderName, relativePath);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
|
||||
File.WriteAllBytes(filePath, Array.Empty<byte>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 212d27ffec81bcb48a886db924f43e1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user