From 27ed1e0e7b3689bdbd950426be8ebc127883d720 Mon Sep 17 00:00:00 2001 From: Efrain Bastidas Date: Wed, 31 Aug 2022 20:34:11 -0500 Subject: [PATCH] [Tests] Minor sanity checks --- test/common.dart | 29 +++++++++++++++++-- .../file/character_file_service_test.dart | 10 +++++-- .../file/weapon_file_service_test.dart | 6 ++++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/test/common.dart b/test/common.dart index 8d77e4949..fdb9bbcb5 100644 --- a/test/common.dart +++ b/test/common.dart @@ -108,20 +108,45 @@ void checkItemAscensionMaterialFileModel(MaterialFileService materialFileService } } -void checkCharacterFileAscensionMaterialModel(MaterialFileService materialFileService, List all) { +void checkCharacterFileAscensionMaterialModel( + MaterialFileService materialFileService, + List all, { + bool checkMaterialType = true, +}) { expect(all, isNotEmpty); for (final ascMaterial in all) { expect(ascMaterial.rank, allOf([greaterThanOrEqualTo(1), lessThanOrEqualTo(6)])); expect(ascMaterial.level, allOf([greaterThanOrEqualTo(20), lessThanOrEqualTo(80)])); checkItemAscensionMaterialFileModel(materialFileService, ascMaterial.materials); + if (checkMaterialType) { + expect(ascMaterial.materials.where((el) => el.type == MaterialType.jewels).length, 1); + expect(ascMaterial.materials.where((el) => el.type == MaterialType.local).length, 1); + expect(ascMaterial.materials.where((el) => el.type == MaterialType.common).length, 1); + expect(ascMaterial.materials.where((el) => el.type == MaterialType.currency).length, 1); + } } } -void checkCharacterFileTalentAscensionMaterialModel(MaterialFileService materialFileService, List all) { +void checkCharacterFileTalentAscensionMaterialModel( + MaterialFileService materialFileService, + List all, { + bool checkMaterialTypeAndLength = true, +}) { expect(all, isNotEmpty); for (final ascMaterial in all) { expect(ascMaterial.level, inInclusiveRange(2, 10)); checkItemAscensionMaterialFileModel(materialFileService, ascMaterial.materials); + + if (checkMaterialTypeAndLength) { + final expectedLengthForTalents = ascMaterial.level == 10 + ? 3 + : ascMaterial.level >= 7 + ? 2 + : 1; + expect(ascMaterial.materials.where((el) => el.type == MaterialType.talents).length, expectedLengthForTalents); + expect(ascMaterial.materials.where((el) => el.type == MaterialType.common).length, 1); + expect(ascMaterial.materials.where((el) => el.type == MaterialType.currency).length, 1); + } } } diff --git a/test/infrastructure/file/character_file_service_test.dart b/test/infrastructure/file/character_file_service_test.dart index faf439879..d69d9479a 100644 --- a/test/infrastructure/file/character_file_service_test.dart +++ b/test/infrastructure/file/character_file_service_test.dart @@ -123,13 +123,17 @@ void main() { expect(detail.stats, isNotEmpty); } - checkCharacterFileAscensionMaterialModel(_service.materials, detail.ascensionMaterials); + checkCharacterFileAscensionMaterialModel(_service.materials, detail.ascensionMaterials, checkMaterialType: !detail.isComingSoon); if (!isTraveler) { - checkCharacterFileTalentAscensionMaterialModel(_service.materials, detail.talentAscensionMaterials); + checkCharacterFileTalentAscensionMaterialModel( + _service.materials, + detail.talentAscensionMaterials, + checkMaterialTypeAndLength: !detail.isComingSoon, + ); } else { for (final ascMaterial in detail.multiTalentAscensionMaterials!) { expect(ascMaterial.number, inInclusiveRange(1, 3)); - checkCharacterFileTalentAscensionMaterialModel(_service.materials, ascMaterial.materials); + checkCharacterFileTalentAscensionMaterialModel(_service.materials, ascMaterial.materials, checkMaterialTypeAndLength: !detail.isComingSoon); } } diff --git a/test/infrastructure/file/weapon_file_service_test.dart b/test/infrastructure/file/weapon_file_service_test.dart index 548bdb37e..106e1c6c2 100644 --- a/test/infrastructure/file/weapon_file_service_test.dart +++ b/test/infrastructure/file/weapon_file_service_test.dart @@ -49,6 +49,12 @@ void main() { checkItemAscensionMaterialFileModel(service.materials, ascMaterial.materials); final expectedLength = i == 0 && detail.rarity == 1 ? 3 : 4; expect(ascMaterial.materials.length, expectedLength); + expect(ascMaterial.materials.where((el) => el.type == MaterialType.weaponPrimary).length, 1); + expect(ascMaterial.materials.where((el) => el.type == MaterialType.weapon).length, 1); + expect(ascMaterial.materials.where((el) => el.type == MaterialType.common).length, 1); + if (expectedLength > 3) { + expect(ascMaterial.materials.where((el) => el.type == MaterialType.currency).length, 1); + } } final ascensionNumber = detail.stats.where((el) => el.isAnAscension).length;