Skip to content

Commit

Permalink
テストコード
Browse files Browse the repository at this point in the history
  • Loading branch information
hkmt-mmy committed Jan 30, 2025
1 parent 28a11ff commit 5afd046
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ internal sealed class ApplyLayoutRuleServiceTest
private const string TestAddressableGroupName = "TestGroup";
private const string TestAssetName = "test_asset.asset";
private const string TestAssetPath = "Assets/Tests/" + TestAssetName;
private const string TestAnotherAssetName = "test_another_asset.asset";
private const string TestAnotherAssetPath = "Assets/Tests/" + TestAnotherAssetName;

[Test]
public void CreateEntry()
Expand All @@ -47,6 +49,46 @@ public void CreateEntry()
Assert.That(assetEntry.Address, Is.EqualTo(TestAssetName));
}

[Test]
public void CreateEntryFromCompositeLayout()
{
var asset1Guid = GUID.Generate().ToString();
var asset2Guid = GUID.Generate().ToString();
var assetType = typeof(ScriptableObject);
const bool isFolder = false;

var layoutRule1 = CreateLayoutRule(TestAddressableGroupName, TestAssetPath, PartialAssetPathType.FileName);
var layoutRule2 = CreateLayoutRule(TestAddressableGroupName, TestAnotherAssetPath,
PartialAssetPathType.FileName);

var assetDatabaseAdapter = new FakeAssetDatabaseAdapter();
assetDatabaseAdapter.Entries.Add(new FakeAssetDatabaseAdapter.Entry(asset1Guid, TestAssetPath, assetType,
isFolder));
assetDatabaseAdapter.Entries.Add(new FakeAssetDatabaseAdapter.Entry(asset2Guid, TestAnotherAssetPath,
assetType, isFolder));

var addressableSettingsAdapter = new FakeAddressableAssetSettingsAdapter();
var service = new ApplyLayoutRuleService(new[] { layoutRule1, layoutRule2 },
new UnityVersionExpressionParser(),
addressableSettingsAdapter,
assetDatabaseAdapter);

layoutRule1.Setup();
layoutRule2.Setup();

service.Apply(asset1Guid, false, false);
service.Apply(asset2Guid, false, false);

var assetEntry1 = addressableSettingsAdapter.FindAssetEntry(asset1Guid);
Assert.That(assetEntry1, Is.Not.Null);
Assert.That(assetEntry1.GroupName, Is.EqualTo(TestAddressableGroupName));
Assert.That(assetEntry1.Address, Is.EqualTo(TestAssetName));
var assetEntry2 = addressableSettingsAdapter.FindAssetEntry(asset2Guid);
Assert.That(assetEntry2, Is.Not.Null);
Assert.That(assetEntry2.GroupName, Is.EqualTo(TestAddressableGroupName));
Assert.That(assetEntry2.Address, Is.EqualTo(TestAnotherAssetName));
}

[Test]
public void PreSetup()
{
Expand Down

0 comments on commit 5afd046

Please sign in to comment.