forked from silfumus/ElectronicObserver
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afddcc7
commit b116b56
Showing
3 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Linq; | ||
using ElectronicObserver.Window.Tools.EquipmentUpgradePlanner; | ||
using ElectronicObserver.Window.Tools.EquipmentUpgradePlanner.UpgradeTree; | ||
using ElectronicObserverTypes; | ||
using Xunit; | ||
|
||
namespace ElectronicObserverCoreTests; | ||
|
||
public class UpgradeTreeTests | ||
{ | ||
private static int GetCount(UpgradeTreeUpgradePlanViewModel plan) => plan.Plan switch | ||
{ | ||
EquipmentUpgradePlanItemViewModel => plan.RequiredCount, | ||
EquipmentConversionPlanItemViewModel conversion => conversion.EquipmentRequiredForUpgradePlan.Count, | ||
EquipmentCraftPlanItemViewModel => plan.RequiredCount, | ||
|
||
_ => throw new NotImplementedException(), | ||
}; | ||
|
||
[Fact(DisplayName = "S-51J kai example")] | ||
public void UpgradeTreeTest1() | ||
{ | ||
EquipmentUpgradePlanItemModel upgradePlan = new() | ||
{ | ||
EquipmentId = EquipmentId.Autogyro_S51JKai, | ||
DesiredUpgradeLevel = UpgradeLevel.Max, | ||
}; | ||
|
||
EquipmentUpgradePlanItemViewModel upgradePlanViewModel = new(upgradePlan); | ||
upgradePlanViewModel.UpdateCosts(); | ||
|
||
UpgradeTreeViewModel tree = new(upgradePlanViewModel); | ||
|
||
UpgradeTreeUpgradePlanViewModel root = tree.Items[0]; | ||
|
||
Assert.NotNull(root.Plan); | ||
Assert.Equal(EquipmentId.Autogyro_S51JKai, root.Plan.EquipmentMasterDataId); | ||
|
||
UpgradeTreeUpgradePlanViewModel? s51jKaiPlan = root.Children | ||
.FirstOrDefault(p => p.Plan?.EquipmentMasterDataId is EquipmentId.Autogyro_S51JKai); | ||
|
||
UpgradeTreeUpgradePlanViewModel? zuiunPlan = root.Children | ||
.FirstOrDefault(p => p.Plan?.EquipmentMasterDataId is EquipmentId.SeaplaneBomber_Zuiun); | ||
|
||
UpgradeTreeUpgradePlanViewModel? t3dcpPlan = root.Children | ||
.FirstOrDefault(p => p.Plan?.EquipmentMasterDataId is EquipmentId.DepthCharge_Type3DepthChargeProjector); | ||
|
||
Assert.NotNull(s51jKaiPlan); | ||
Assert.NotNull(zuiunPlan); | ||
Assert.NotNull(t3dcpPlan); | ||
|
||
Assert.Equal(1, s51jKaiPlan.RequiredCount); | ||
Assert.Equal(12, GetCount(zuiunPlan)); | ||
Assert.Equal(8, GetCount(t3dcpPlan)); | ||
} | ||
} |