S5-01 + S5-02 + S5-03
This commit is contained in:
@@ -75,6 +75,48 @@ namespace GeometryTD.Tests.EditMode
|
||||
Is.EqualTo(CombatParticipantTowerValidationFailureReason.MissingBaseComponent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ValidateTower_Returns_BrokenMuzzle_When_Muzzle_Endurance_Is_Zero()
|
||||
{
|
||||
BackpackInventoryData inventory = CreateInventory();
|
||||
inventory.MuzzleComponents[0].Endurance = 0f;
|
||||
|
||||
CombatParticipantTowerValidationResult result =
|
||||
CombatParticipantTowerValidationService.ValidateTower(inventory, inventory.Towers[0]);
|
||||
|
||||
Assert.That(result.IsValid, Is.False);
|
||||
Assert.That(result.FailureReason,
|
||||
Is.EqualTo(CombatParticipantTowerValidationFailureReason.BrokenMuzzleComponent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ValidateTower_Returns_BrokenBearing_When_Bearing_Endurance_Is_Zero()
|
||||
{
|
||||
BackpackInventoryData inventory = CreateInventory();
|
||||
inventory.BearingComponents[0].Endurance = 0f;
|
||||
|
||||
CombatParticipantTowerValidationResult result =
|
||||
CombatParticipantTowerValidationService.ValidateTower(inventory, inventory.Towers[0]);
|
||||
|
||||
Assert.That(result.IsValid, Is.False);
|
||||
Assert.That(result.FailureReason,
|
||||
Is.EqualTo(CombatParticipantTowerValidationFailureReason.BrokenBearingComponent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ValidateTower_Returns_BrokenBase_When_Base_Endurance_Is_Zero()
|
||||
{
|
||||
BackpackInventoryData inventory = CreateInventory();
|
||||
inventory.BaseComponents[0].Endurance = 0f;
|
||||
|
||||
CombatParticipantTowerValidationResult result =
|
||||
CombatParticipantTowerValidationService.ValidateTower(inventory, inventory.Towers[0]);
|
||||
|
||||
Assert.That(result.IsValid, Is.False);
|
||||
Assert.That(result.FailureReason,
|
||||
Is.EqualTo(CombatParticipantTowerValidationFailureReason.BrokenBaseComponent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ValidateParticipantTowers_Splits_Valid_And_Invalid_Towers()
|
||||
{
|
||||
@@ -103,19 +145,19 @@ namespace GeometryTD.Tests.EditMode
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ValidateParticipantTowers_Treats_Zero_Endurance_As_Valid_For_S3_01()
|
||||
public void ValidateParticipantTowers_Treats_Zero_Endurance_As_Invalid_For_S5_02()
|
||||
{
|
||||
BackpackInventoryData inventory = CreateInventory();
|
||||
inventory.MuzzleComponents[0].Endurance = 0f;
|
||||
inventory.BearingComponents[0].Endurance = 0f;
|
||||
inventory.BaseComponents[0].Endurance = 0f;
|
||||
|
||||
CombatParticipantTowerValidationSummary summary =
|
||||
CombatParticipantTowerValidationService.ValidateParticipantTowers(inventory);
|
||||
|
||||
Assert.That(summary.HasAnyValidParticipantTower, Is.True);
|
||||
Assert.That(summary.ValidTowers.Count, Is.EqualTo(1));
|
||||
Assert.That(summary.InvalidResults.Count, Is.EqualTo(0));
|
||||
Assert.That(summary.HasAnyValidParticipantTower, Is.False);
|
||||
Assert.That(summary.ValidTowers.Count, Is.EqualTo(0));
|
||||
Assert.That(summary.InvalidResults.Count, Is.EqualTo(1));
|
||||
Assert.That(summary.InvalidResults[0].FailureReason,
|
||||
Is.EqualTo(CombatParticipantTowerValidationFailureReason.BrokenMuzzleComponent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using GeometryTD.CustomComponent;
|
||||
using GeometryTD.DataTable;
|
||||
using GeometryTD.Definition;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GeometryTD.Tests.EditMode
|
||||
{
|
||||
public sealed class CombatSettlementServiceTests
|
||||
{
|
||||
private const int MaxParticipantTowerCount = 4;
|
||||
|
||||
private GameObject _inventoryObject;
|
||||
private PlayerInventoryComponent _originalPlayerInventory;
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
SetStaticPlayerInventory(_originalPlayerInventory);
|
||||
if (_inventoryObject != null)
|
||||
{
|
||||
Object.DestroyImmediate(_inventoryObject);
|
||||
_inventoryObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildSettlementContext_Captures_CombatStart_Participant_Tower_Ids_And_Fixed_Endurance_Loss()
|
||||
{
|
||||
PlayerInventoryComponent inventoryComponent = CreateBoundPlayerInventory(CreateInventory(100f, 100f, 100f));
|
||||
CombatRunResourceStore resourceStore = new CombatRunResourceStore();
|
||||
DRLevel level = CreateLevel(baseHp: 100, startCoin: 20, rewardGold: 30);
|
||||
resourceStore.InitializeForCombat(level);
|
||||
|
||||
BackpackInventoryData changedInventory = inventoryComponent.GetInventorySnapshot();
|
||||
changedInventory.ParticipantTowerInstanceIds.Clear();
|
||||
changedInventory.ParticipantTowerInstanceIds.Add(90003);
|
||||
inventoryComponent.ReplaceInventorySnapshot(changedInventory);
|
||||
|
||||
CombatSettlementContext settlementContext = new CombatSettlementService().BuildSettlementContext(
|
||||
didCombatWin: false,
|
||||
currentLevel: level,
|
||||
defeatedEnemyCount: 4,
|
||||
resourceStore: resourceStore);
|
||||
|
||||
CollectionAssert.AreEqual(
|
||||
new long[] { 90001, 90002 },
|
||||
settlementContext.Result.Endurance.TargetTowerInstanceIds);
|
||||
Assert.That(settlementContext.Result.Endurance.EnduranceLossPerComponent, Is.EqualTo(1f));
|
||||
Assert.That(settlementContext.Flags.ShouldOpenRewardSelection, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CommitSettlementInventory_Reduces_Only_CombatStart_Participant_Towers()
|
||||
{
|
||||
PlayerInventoryComponent inventoryComponent = CreateBoundPlayerInventory(CreateInventory(100f, 100f, 100f));
|
||||
CombatRunResourceStore resourceStore = new CombatRunResourceStore();
|
||||
DRLevel level = CreateLevel(baseHp: 100, startCoin: 20, rewardGold: 30);
|
||||
resourceStore.InitializeForCombat(level);
|
||||
|
||||
BackpackInventoryData changedInventory = inventoryComponent.GetInventorySnapshot();
|
||||
changedInventory.ParticipantTowerInstanceIds.Clear();
|
||||
changedInventory.ParticipantTowerInstanceIds.Add(90003);
|
||||
inventoryComponent.ReplaceInventorySnapshot(changedInventory);
|
||||
|
||||
CombatSettlementService settlementService = new CombatSettlementService();
|
||||
CombatSettlementContext settlementContext = settlementService.BuildSettlementContext(
|
||||
didCombatWin: false,
|
||||
currentLevel: level,
|
||||
defeatedEnemyCount: 2,
|
||||
resourceStore: resourceStore);
|
||||
|
||||
settlementService.CommitSettlementInventory(settlementContext);
|
||||
|
||||
BackpackInventoryData committedInventory = inventoryComponent.GetInventorySnapshot();
|
||||
Assert.That(GetTowerComponents(committedInventory, 90001).Muzzle.Endurance, Is.EqualTo(99f));
|
||||
Assert.That(GetTowerComponents(committedInventory, 90002).Muzzle.Endurance, Is.EqualTo(99f));
|
||||
Assert.That(GetTowerComponents(committedInventory, 90003).Muzzle.Endurance, Is.EqualTo(100f));
|
||||
Assert.That(settlementContext.Result.Endurance.AffectedTowerCount, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CommitSettlementInventory_Reduces_Endurance_To_Zero_And_Next_Validation_Fails()
|
||||
{
|
||||
PlayerInventoryComponent inventoryComponent = CreateBoundPlayerInventory(CreateInventory(1f, 100f, 100f));
|
||||
CombatRunResourceStore resourceStore = new CombatRunResourceStore();
|
||||
DRLevel level = CreateLevel(baseHp: 100, startCoin: 20, rewardGold: 30);
|
||||
resourceStore.InitializeForCombat(level);
|
||||
|
||||
CombatSettlementService settlementService = new CombatSettlementService();
|
||||
CombatSettlementContext settlementContext = settlementService.BuildSettlementContext(
|
||||
didCombatWin: true,
|
||||
currentLevel: level,
|
||||
defeatedEnemyCount: 6,
|
||||
resourceStore: resourceStore);
|
||||
|
||||
settlementService.CommitSettlementInventory(settlementContext);
|
||||
|
||||
BackpackInventoryData committedInventory = inventoryComponent.GetInventorySnapshot();
|
||||
CombatParticipantTowerValidationSummary summary =
|
||||
CombatParticipantTowerValidationService.ValidateParticipantTowers(committedInventory);
|
||||
|
||||
Assert.That(GetTowerComponents(committedInventory, 90001).Muzzle.Endurance, Is.EqualTo(0f));
|
||||
Assert.That(summary.HasAnyValidParticipantTower, Is.True);
|
||||
Assert.That(summary.InvalidResults.Count, Is.EqualTo(1));
|
||||
Assert.That(
|
||||
summary.InvalidResults[0].FailureReason,
|
||||
Is.EqualTo(CombatParticipantTowerValidationFailureReason.BrokenMuzzleComponent));
|
||||
}
|
||||
|
||||
private PlayerInventoryComponent CreateBoundPlayerInventory(BackpackInventoryData inventory)
|
||||
{
|
||||
_originalPlayerInventory = GameEntry.PlayerInventory;
|
||||
_inventoryObject = new GameObject("TestPlayerInventory");
|
||||
PlayerInventoryComponent inventoryComponent = _inventoryObject.AddComponent<PlayerInventoryComponent>();
|
||||
SetStaticPlayerInventory(inventoryComponent);
|
||||
inventoryComponent.ReplaceInventorySnapshot(inventory);
|
||||
return inventoryComponent;
|
||||
}
|
||||
|
||||
private static void SetStaticPlayerInventory(PlayerInventoryComponent inventoryComponent)
|
||||
{
|
||||
FieldInfo backingField = typeof(GameEntry).GetField(
|
||||
"<PlayerInventory>k__BackingField",
|
||||
BindingFlags.Static | BindingFlags.NonPublic);
|
||||
Assert.That(backingField, Is.Not.Null);
|
||||
backingField.SetValue(null, inventoryComponent);
|
||||
}
|
||||
|
||||
private static DRLevel CreateLevel(int baseHp, int startCoin, int rewardGold)
|
||||
{
|
||||
DRLevel level = new DRLevel();
|
||||
bool parsed = level.ParseDataRow(
|
||||
$"\t1\t测试关卡\tPlain\t{baseHp}\t{startCoin}\tWaveCount\t10\t{rewardGold}",
|
||||
null);
|
||||
Assert.That(parsed, Is.True);
|
||||
return level;
|
||||
}
|
||||
|
||||
private static BackpackInventoryData CreateInventory(
|
||||
float firstTowerEndurance,
|
||||
float secondTowerEndurance,
|
||||
float thirdTowerEndurance)
|
||||
{
|
||||
BackpackInventoryData inventory = new BackpackInventoryData();
|
||||
AddTower(inventory, 90001, 10001, 20001, 30001, firstTowerEndurance, isParticipant: true);
|
||||
AddTower(inventory, 90002, 10002, 20002, 30002, secondTowerEndurance, isParticipant: true);
|
||||
AddTower(inventory, 90003, 10003, 20003, 30003, thirdTowerEndurance, isParticipant: false);
|
||||
return inventory;
|
||||
}
|
||||
|
||||
private static void AddTower(
|
||||
BackpackInventoryData inventory,
|
||||
long towerId,
|
||||
long muzzleId,
|
||||
long bearingId,
|
||||
long baseId,
|
||||
float endurance,
|
||||
bool isParticipant)
|
||||
{
|
||||
inventory.MuzzleComponents.Add(new MuzzleCompItemData { InstanceId = muzzleId, Endurance = endurance });
|
||||
inventory.BearingComponents.Add(new BearingCompItemData { InstanceId = bearingId, Endurance = endurance });
|
||||
inventory.BaseComponents.Add(new BaseCompItemData { InstanceId = baseId, Endurance = endurance });
|
||||
inventory.Towers.Add(new TowerItemData
|
||||
{
|
||||
InstanceId = towerId,
|
||||
MuzzleComponentInstanceId = muzzleId,
|
||||
BearingComponentInstanceId = bearingId,
|
||||
BaseComponentInstanceId = baseId,
|
||||
IsParticipatingInCombat = isParticipant,
|
||||
Stats = new TowerStatsData()
|
||||
});
|
||||
|
||||
if (isParticipant && inventory.ParticipantTowerInstanceIds.Count < MaxParticipantTowerCount)
|
||||
{
|
||||
inventory.ParticipantTowerInstanceIds.Add(towerId);
|
||||
}
|
||||
}
|
||||
|
||||
private static (MuzzleCompItemData Muzzle, BearingCompItemData Bearing, BaseCompItemData Base) GetTowerComponents(
|
||||
BackpackInventoryData inventory,
|
||||
long towerInstanceId)
|
||||
{
|
||||
TowerItemData tower = inventory.Towers.Find(item => item.InstanceId == towerInstanceId);
|
||||
Assert.That(tower, Is.Not.Null);
|
||||
MuzzleCompItemData muzzle = inventory.MuzzleComponents.Find(item => item.InstanceId == tower.MuzzleComponentInstanceId);
|
||||
BearingCompItemData bearing = inventory.BearingComponents.Find(item => item.InstanceId == tower.BearingComponentInstanceId);
|
||||
BaseCompItemData baseComp = inventory.BaseComponents.Find(item => item.InstanceId == tower.BaseComponentInstanceId);
|
||||
Assert.That(muzzle, Is.Not.Null);
|
||||
Assert.That(bearing, Is.Not.Null);
|
||||
Assert.That(baseComp, Is.Not.Null);
|
||||
return (muzzle, bearing, baseComp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a9e6c3fb1d84d6db2455d4c13f0e2b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -51,6 +51,21 @@ namespace GeometryTD.Tests.EditMode
|
||||
Assert.That(inventory.ParticipantTowerInstanceIds.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryAddParticipantTower_Returns_InvalidTower_With_Broken_Component_Reason()
|
||||
{
|
||||
BackpackInventoryData inventory = CreateValidInventory();
|
||||
inventory.MuzzleComponents[0].Endurance = 0f;
|
||||
|
||||
ParticipantTowerAssignResult result = InventoryParticipantUtility.TryAddParticipantTower(inventory, 90001, 4);
|
||||
|
||||
Assert.That(result.IsSuccess, Is.False);
|
||||
Assert.That(result.FailureReason, Is.EqualTo(ParticipantTowerAssignFailureReason.InvalidTower));
|
||||
Assert.That(result.ValidationFailureReason,
|
||||
Is.EqualTo(CombatParticipantTowerValidationFailureReason.BrokenMuzzleComponent));
|
||||
Assert.That(inventory.ParticipantTowerInstanceIds.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryAddParticipantTower_Returns_AlreadyAssigned_Without_Duplicating_List()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
using GeometryTD.CustomComponent;
|
||||
using GeometryTD.CustomUtility;
|
||||
using GeometryTD.Definition;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GeometryTD.Tests.EditMode
|
||||
{
|
||||
public sealed class PlayerInventoryTowerRosterServiceTests
|
||||
{
|
||||
[Test]
|
||||
public void ReduceTowerEndurance_Reduces_Only_Target_Towers_And_Deduplicates_Ids()
|
||||
{
|
||||
BackpackInventoryData inventory = CreateInventory(100f, 100f, 100f);
|
||||
PlayerInventoryTowerRosterService service = CreateService(inventory, out PlayerInventoryQueryModel queryModel);
|
||||
|
||||
int affectedTowerCount = service.ReduceTowerEndurance(new long[] { 90001, 90001, 90002 }, 1f);
|
||||
|
||||
Assert.That(affectedTowerCount, Is.EqualTo(2));
|
||||
Assert.That(GetTowerComponents(queryModel.Inventory, 90001).Muzzle.Endurance, Is.EqualTo(99f));
|
||||
Assert.That(GetTowerComponents(queryModel.Inventory, 90001).Bearing.Endurance, Is.EqualTo(99f));
|
||||
Assert.That(GetTowerComponents(queryModel.Inventory, 90001).Base.Endurance, Is.EqualTo(99f));
|
||||
Assert.That(GetTowerComponents(queryModel.Inventory, 90002).Muzzle.Endurance, Is.EqualTo(99f));
|
||||
Assert.That(GetTowerComponents(queryModel.Inventory, 90003).Muzzle.Endurance, Is.EqualTo(100f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReduceTowerEndurance_Clamps_Component_Endurance_To_Zero()
|
||||
{
|
||||
BackpackInventoryData inventory = CreateInventory(1f, 1f, 1f);
|
||||
PlayerInventoryTowerRosterService service = CreateService(inventory, out PlayerInventoryQueryModel queryModel);
|
||||
|
||||
int affectedTowerCount = service.ReduceTowerEndurance(new long[] { 90001 }, 5f);
|
||||
|
||||
Assert.That(affectedTowerCount, Is.EqualTo(1));
|
||||
Assert.That(GetTowerComponents(queryModel.Inventory, 90001).Muzzle.Endurance, Is.EqualTo(0f));
|
||||
Assert.That(GetTowerComponents(queryModel.Inventory, 90001).Bearing.Endurance, Is.EqualTo(0f));
|
||||
Assert.That(GetTowerComponents(queryModel.Inventory, 90001).Base.Endurance, Is.EqualTo(0f));
|
||||
}
|
||||
|
||||
private static PlayerInventoryTowerRosterService CreateService(
|
||||
BackpackInventoryData inventory,
|
||||
out PlayerInventoryQueryModel queryModel)
|
||||
{
|
||||
PlayerInventoryState state = new PlayerInventoryState();
|
||||
queryModel = new PlayerInventoryQueryModel(state);
|
||||
PlayerInventoryCommandModel commandModel = new PlayerInventoryCommandModel(state);
|
||||
commandModel.Initialize(inventory, 4);
|
||||
return new PlayerInventoryTowerRosterService(queryModel, 4);
|
||||
}
|
||||
|
||||
private static BackpackInventoryData CreateInventory(
|
||||
float firstTowerEndurance,
|
||||
float secondTowerEndurance,
|
||||
float thirdTowerEndurance)
|
||||
{
|
||||
BackpackInventoryData inventory = new BackpackInventoryData();
|
||||
AddTower(inventory, 90001, 10001, 20001, 30001, firstTowerEndurance);
|
||||
AddTower(inventory, 90002, 10002, 20002, 30002, secondTowerEndurance);
|
||||
AddTower(inventory, 90003, 10003, 20003, 30003, thirdTowerEndurance);
|
||||
return inventory;
|
||||
}
|
||||
|
||||
private static void AddTower(
|
||||
BackpackInventoryData inventory,
|
||||
long towerId,
|
||||
long muzzleId,
|
||||
long bearingId,
|
||||
long baseId,
|
||||
float endurance)
|
||||
{
|
||||
inventory.MuzzleComponents.Add(new MuzzleCompItemData { InstanceId = muzzleId, Endurance = endurance });
|
||||
inventory.BearingComponents.Add(new BearingCompItemData { InstanceId = bearingId, Endurance = endurance });
|
||||
inventory.BaseComponents.Add(new BaseCompItemData { InstanceId = baseId, Endurance = endurance });
|
||||
inventory.Towers.Add(new TowerItemData
|
||||
{
|
||||
InstanceId = towerId,
|
||||
MuzzleComponentInstanceId = muzzleId,
|
||||
BearingComponentInstanceId = bearingId,
|
||||
BaseComponentInstanceId = baseId,
|
||||
Stats = new TowerStatsData()
|
||||
});
|
||||
}
|
||||
|
||||
private static (MuzzleCompItemData Muzzle, BearingCompItemData Bearing, BaseCompItemData Base) GetTowerComponents(
|
||||
BackpackInventoryData inventory,
|
||||
long towerInstanceId)
|
||||
{
|
||||
Assert.That(InventoryParticipantUtility.TryGetTowerById(inventory, towerInstanceId, out TowerItemData tower), Is.True);
|
||||
MuzzleCompItemData muzzle = inventory.MuzzleComponents.Find(item => item.InstanceId == tower.MuzzleComponentInstanceId);
|
||||
BearingCompItemData bearing = inventory.BearingComponents.Find(item => item.InstanceId == tower.BearingComponentInstanceId);
|
||||
BaseCompItemData baseComp = inventory.BaseComponents.Find(item => item.InstanceId == tower.BaseComponentInstanceId);
|
||||
Assert.That(muzzle, Is.Not.Null);
|
||||
Assert.That(bearing, Is.Not.Null);
|
||||
Assert.That(baseComp, Is.Not.Null);
|
||||
return (muzzle, bearing, baseComp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3f4e9c1b7a24a1f8e0a9db7c2e5416b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -217,6 +217,24 @@ namespace GeometryTD.Tests.EditMode
|
||||
Is.EqualTo(CombatParticipantTowerValidationFailureReason.MissingBaseComponent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ValidateCombatEntry_Returns_NoValidParticipantTower_When_AllParticipantTowers_Are_Broken()
|
||||
{
|
||||
BackpackInventoryData inventory = CreateCombatInventory();
|
||||
inventory.MuzzleComponents[0].Endurance = 0f;
|
||||
|
||||
ProcedureMainCombatEntryValidationResult result =
|
||||
ProcedureMainCombatEntryValidationService.Validate(inventory);
|
||||
|
||||
Assert.That(result.CanEnterCombat, Is.False);
|
||||
Assert.That(result.BlockReason, Is.EqualTo(ProcedureMainCombatEntryBlockReason.NoValidParticipantTower));
|
||||
Assert.That(result.ValidationSummary.ValidTowers.Count, Is.EqualTo(0));
|
||||
Assert.That(result.ValidationSummary.InvalidResults.Count, Is.EqualTo(1));
|
||||
Assert.That(
|
||||
result.ValidationSummary.InvalidResults[0].FailureReason,
|
||||
Is.EqualTo(CombatParticipantTowerValidationFailureReason.BrokenMuzzleComponent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ValidateCombatEntry_Returns_CanEnter_When_At_Least_One_ParticipantTower_Is_Valid()
|
||||
{
|
||||
@@ -336,6 +354,36 @@ namespace GeometryTD.Tests.EditMode
|
||||
Is.EqualTo("参战区没有可出战的完整塔。\n塔 #90002 缺少底座组件。\n塔 #90003 缺少枪口组件。"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildBlockedCombatDialogRawData_Lists_Broken_Component_Reasons()
|
||||
{
|
||||
DialogFormRawData rawData = ProcedureMainCombatEntryValidationService.BuildBlockedCombatDialogRawData(
|
||||
new ProcedureMainCombatEntryValidationResult
|
||||
{
|
||||
BlockReason = ProcedureMainCombatEntryBlockReason.NoValidParticipantTower,
|
||||
ValidationSummary = new CombatParticipantTowerValidationSummary
|
||||
{
|
||||
InvalidResults = new[]
|
||||
{
|
||||
new CombatParticipantTowerValidationResult
|
||||
{
|
||||
TowerInstanceId = 90002,
|
||||
FailureReason = CombatParticipantTowerValidationFailureReason.BrokenBaseComponent
|
||||
},
|
||||
new CombatParticipantTowerValidationResult
|
||||
{
|
||||
TowerInstanceId = 90003,
|
||||
FailureReason = CombatParticipantTowerValidationFailureReason.BrokenMuzzleComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Assert.That(
|
||||
rawData.Message,
|
||||
Is.EqualTo("参战区没有可出战的完整塔。\n塔 #90002 底座组件耐久为 0,无法参战。\n塔 #90003 枪口组件耐久为 0,无法参战。"));
|
||||
}
|
||||
|
||||
private static RunState CreateTwoNodeRun()
|
||||
{
|
||||
return RunStateFactory.Create(
|
||||
|
||||
Reference in New Issue
Block a user