From 4273d6eee81c855b5447d632a9b195c6097a3e34 Mon Sep 17 00:00:00 2001 From: Haruki Yano Date: Thu, 18 Jan 2024 17:28:54 +0900 Subject: [PATCH] fix tests --- .../Services/ApplyLayoutRuleServiceTest.cs | 16 ++++++++-------- .../FakeAddressableAssetSettingsAdapter.cs | 11 ++++++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Assets/SmartAddresser/Tests/Editor/Core/Models/Services/ApplyLayoutRuleServiceTest.cs b/Assets/SmartAddresser/Tests/Editor/Core/Models/Services/ApplyLayoutRuleServiceTest.cs index eda25ba..6599310 100644 --- a/Assets/SmartAddresser/Tests/Editor/Core/Models/Services/ApplyLayoutRuleServiceTest.cs +++ b/Assets/SmartAddresser/Tests/Editor/Core/Models/Services/ApplyLayoutRuleServiceTest.cs @@ -38,7 +38,7 @@ public void CreateEntry() var service = new ApplyLayoutRuleService(layoutRule, new UnityVersionExpressionParser(), addressableSettingsAdapter, assetDatabaseAdapter); - var result = service.TryAddEntry(assetGuid, true); + var result = service.TryAddEntry(assetGuid, true, false); var assetEntry = addressableSettingsAdapter.FindAssetEntry(assetGuid); Assert.That(result, Is.True); Assert.That(assetEntry, Is.Not.Null); @@ -61,7 +61,7 @@ public void PreSetup() addressableSettingsAdapter, assetDatabaseAdapter); service.Setup(); - var result = service.TryAddEntry(assetGuid, false); + var result = service.TryAddEntry(assetGuid, false, false); var assetEntry = addressableSettingsAdapter.FindAssetEntry(assetGuid); Assert.That(result, Is.True); Assert.That(assetEntry, Is.Not.Null); @@ -84,7 +84,7 @@ public void MatchedLayoutRuleNotExists_ReturnFalse() var service = new ApplyLayoutRuleService(layoutRule, new UnityVersionExpressionParser(), addressableSettingsAdapter, assetDatabaseAdapter); - var result = service.TryAddEntry(assetGuid, true); + var result = service.TryAddEntry(assetGuid, true, false); Assert.That(result, Is.False); } @@ -103,7 +103,7 @@ public void GroupIsNull_ReturnFalse() var service = new ApplyLayoutRuleService(layoutRule, new UnityVersionExpressionParser(), addressableSettingsAdapter, assetDatabaseAdapter); - var result = service.TryAddEntry(assetGuid, true); + var result = service.TryAddEntry(assetGuid, true, false); Assert.That(result, Is.False); } @@ -122,7 +122,7 @@ public void VersionIsSatisfied() var service = new ApplyLayoutRuleService(layoutRule, new UnityVersionExpressionParser(), addressableSettingsAdapter, assetDatabaseAdapter); - var result = service.TryAddEntry(assetGuid, true, "[1.2.3,1.2.4)"); + var result = service.TryAddEntry(assetGuid, true, false, "[1.2.3,1.2.4)"); var assetEntry = addressableSettingsAdapter.FindAssetEntry(assetGuid); Assert.That(result, Is.True); Assert.That(assetEntry, Is.Not.Null); @@ -145,7 +145,7 @@ public void VersionIsNotSatisfied_ReturnFalse() var service = new ApplyLayoutRuleService(layoutRule, new UnityVersionExpressionParser(), addressableSettingsAdapter, assetDatabaseAdapter); - var result = service.TryAddEntry(assetGuid, true, "(1.2.3,1.3)"); + var result = service.TryAddEntry(assetGuid, true, false, "(1.2.3,1.3)"); Assert.That(result, Is.False); } @@ -164,7 +164,7 @@ public void InvalidVersionExpression_Exception() var service = new ApplyLayoutRuleService(layoutRule, new UnityVersionExpressionParser(), addressableSettingsAdapter, assetDatabaseAdapter); - Assert.That(() => service.TryAddEntry(assetGuid, true, "(1.2.3, 1.3)"), Throws.InstanceOf()); + Assert.That(() => service.TryAddEntry(assetGuid, true, false, "(1.2.3, 1.3)"), Throws.InstanceOf()); } [Test] @@ -183,7 +183,7 @@ public void SetLabel() var service = new ApplyLayoutRuleService(layoutRule, new UnityVersionExpressionParser(), addressableSettingsAdapter, assetDatabaseAdapter); - var result = service.TryAddEntry(assetGuid, true); + var result = service.TryAddEntry(assetGuid, true, false); var assetEntry = addressableSettingsAdapter.FindAssetEntry(assetGuid); Assert.That(result, Is.True); Assert.That(assetEntry, Is.Not.Null); diff --git a/Assets/SmartAddresser/Tests/Editor/Foundation/FakeAddressableAssetSettingsAdapter.cs b/Assets/SmartAddresser/Tests/Editor/Foundation/FakeAddressableAssetSettingsAdapter.cs index 8ba6f0f..a486d7e 100644 --- a/Assets/SmartAddresser/Tests/Editor/Foundation/FakeAddressableAssetSettingsAdapter.cs +++ b/Assets/SmartAddresser/Tests/Editor/Foundation/FakeAddressableAssetSettingsAdapter.cs @@ -16,7 +16,7 @@ public IAddressableAssetEntryAdapter FindAssetEntry(string guid) } /// - public IAddressableAssetEntryAdapter CreateOrMoveEntry(string groupName, string guid) + public IAddressableAssetEntryAdapter CreateOrMoveEntry(string groupName, string guid, bool invokeModificationEvent) { if (_guidToEntryMap.TryGetValue(guid, out var entry)) { @@ -36,12 +36,12 @@ public IAddressableAssetEntryAdapter CreateOrMoveEntry(string groupName, string } /// - public bool RemoveEntry(string guid) + public bool RemoveEntry(string guid, bool invokeModificationEvent) { return _guidToEntryMap.Remove(guid); } - public void RemoveAllEntries(string groupName) + public void RemoveAllEntries(string groupName, bool invokeModificationEvent) { var targetGuids = _guidToEntryMap .Values @@ -52,6 +52,11 @@ public void RemoveAllEntries(string groupName) _guidToEntryMap.Remove(guid); } + public void InvokeBatchModificationEvent() + { + // Do nothing when testing. + } + /// public IReadOnlyList GetLabels() {