init
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6548af31e4534ab6a234772ebdb1cbe8
|
||||
timeCreated: 1696336019
|
||||
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using Test.Util;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Objects.Abstract;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class AbstractObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets("t:GameObject").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var abstractObjects = gameObject.GetComponentsInChildren<AbstractObject>();
|
||||
|
||||
// If prefab have any AbstractObject or any its children anywhere - take it, we will test it
|
||||
if (abstractObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Obsolete("Obsolete", false)]
|
||||
public void IsPrefab()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var isPrefab = PrefabUtility.GetPrefabParent(gameObject) == null &&
|
||||
PrefabUtility.GetPrefabObject(gameObject) != null;
|
||||
|
||||
if (isPrefab) return;
|
||||
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
Debug.LogError(
|
||||
$"{prefabPathHyperlink} is not prefab, instances of '{nameof(AbstractObject)}' should be placed only on main GameObject of prefab",
|
||||
gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OnlyOnePerPrefab()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var abstractObject = gameObject.GetComponentsInChildren<AbstractObject>();
|
||||
|
||||
if (abstractObject.Length == 1) return;
|
||||
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
Debug.LogError($"Prefab: {prefabPathHyperlink}, prefab have attached more than one instance of '{nameof(AbstractObject)}'", gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OnlyInPrefabRoot()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var abstractObject = gameObject.GetComponent<AbstractObject>();
|
||||
var insideAbstractObject = gameObject.GetComponentsInChildren<AbstractObject>().ToList();
|
||||
insideAbstractObject.Remove(abstractObject);
|
||||
|
||||
if (insideAbstractObject.Count == 0) return;
|
||||
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
Debug.LogError($"Prefab: {prefabPathHyperlink}, any instance of '{nameof(AbstractObject)}' should be placed ONLY on main GameObject of prefab, not inside its children", abstractObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BasicData_DisplayName()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var abstractObject = gameObject.GetComponent<AbstractObject>();
|
||||
|
||||
if (!abstractObject) return;
|
||||
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
var name = abstractObject.basicData.finalName;
|
||||
var trimName = name.Trim();
|
||||
|
||||
if (!name.Equals(trimName))
|
||||
Debug.LogWarning(
|
||||
$"Prefab's display name trimmed is different (contain whitespaces at start or end): {prefabPathHyperlink}");
|
||||
|
||||
if (trimName.Length > 0) return;
|
||||
|
||||
Debug.LogError($"Prefab's display name is empty: {prefabPathHyperlink}", abstractObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitData_Size()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var abstractObject = gameObject.GetComponent<AbstractObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
if (abstractObject.basicData.height <= 0f)
|
||||
Debug.LogError($"{nameof(AbstractObject)}'s height is lesser or equal to zero: {prefabPathHyperlink}", abstractObject);
|
||||
|
||||
if (abstractObject.basicData.radius <= 0f)
|
||||
Debug.LogWarning($"{nameof(AbstractObject)}'s width is lesser or equal to zero: {prefabPathHyperlink}", abstractObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BasicData_BasicResources()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var abstractObject = gameObject.GetComponent<AbstractObject>();
|
||||
|
||||
if (!abstractObject) return;
|
||||
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
var health = abstractObject.basicData.currentResources.health;
|
||||
var baseHealth = abstractObject.basicData.baseMaxResources.health;
|
||||
|
||||
if (baseHealth <= 0f)
|
||||
Debug.LogError($"Prefab's baseHealth cannot be 0 or lower: {prefabPathHyperlink}", abstractObject);
|
||||
|
||||
if (health > baseHealth)
|
||||
Debug.LogError($"Prefab's current health is greater than baseMaxHealth: {prefabPathHyperlink}", abstractObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StatusManager_DuplicatedStatuses()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var abstractObject = gameObject.GetComponent<AbstractObject>();
|
||||
if (!abstractObject) return;
|
||||
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
var statuses = abstractObject.statusManager.GetStatuses().ToList();
|
||||
|
||||
if (statuses.Distinct().Count() != statuses.Count)
|
||||
Debug.LogError($"Prefab's '{nameof(AbstractObjectStatusManager)}' contain duplicated statuses: {prefabPathHyperlink}", abstractObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StatusManager_InvalidStatusCombination()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var abstractObject = gameObject.GetComponent<AbstractObject>();
|
||||
if (!abstractObject) return;
|
||||
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
var statuses = abstractObject.statusManager.GetStatuses().ToList();
|
||||
|
||||
statuses.ForEach(status =>
|
||||
{
|
||||
statuses
|
||||
.Where(otherStatus => otherStatus != status)
|
||||
.Where(otherStatus => status.removes.Contains(otherStatus))
|
||||
.ForEach(invalidStatus =>
|
||||
Debug.LogError($"Invalid combination of '{status.displayName}' and '{invalidStatus.displayName}': {prefabPathHyperlink}", abstractObject));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0708d3cd3e664e849603f44f5f610946
|
||||
timeCreated: 1673982582
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Armor;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class ArmorObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets($"t:{nameof(GameObject)}").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var armorObjects = gameObject.GetComponentsInChildren<ArmorObject>();
|
||||
|
||||
// Only armor for current testing
|
||||
if (armorObjects.All(belt => belt.armorData.armorType != ArmorType.Armor)) return;
|
||||
|
||||
// If prefab have any ArmorObject - take it, we will test it
|
||||
if (armorObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NothingToTest()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bffcfe898344c8f9f350278695712e3
|
||||
timeCreated: 1674151243
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Armor;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class BeltObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets($"t:{nameof(GameObject)}").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var beltObjects = gameObject.GetComponentsInChildren<ArmorObject>();
|
||||
|
||||
// Only belt for current testing
|
||||
if (beltObjects.All(belt => belt.armorData.armorType != ArmorType.Belt)) return;
|
||||
|
||||
// If prefab have any ArmorObject - take it, we will test it
|
||||
if (beltObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NothingToTest()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1bb5a185eceb4ac8b9dc6a1f0f40f9bf
|
||||
timeCreated: 1674151497
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Armor;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class BootsObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets($"t:{nameof(GameObject)}").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var bootsObjects = gameObject.GetComponentsInChildren<ArmorObject>();
|
||||
|
||||
// Only boots for current testing
|
||||
if (bootsObjects.All(belt => belt.armorData.armorType != ArmorType.Boots)) return;
|
||||
|
||||
// If prefab have any ArmorObject - take it, we will test it
|
||||
if (bootsObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NothingToTest()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60e8dab59c0e478d9aa753d0d13836c1
|
||||
timeCreated: 1674151529
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Armor;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class GlovesObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets($"t:{nameof(GameObject)}").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var glovesObjects = gameObject.GetComponentsInChildren<ArmorObject>();
|
||||
|
||||
// Only gloves for current testing
|
||||
if (glovesObjects.All(belt => belt.armorData.armorType != ArmorType.Gloves)) return;
|
||||
|
||||
// If prefab have any ArmorObject - take it, we will test it
|
||||
if (glovesObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NothingToTest()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48781c9119a94303a8484f83d06dcbdb
|
||||
timeCreated: 1674151554
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Armor;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class HelmetObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets($"t:{nameof(GameObject)}").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var helmetObjects = gameObject.GetComponentsInChildren<ArmorObject>();
|
||||
|
||||
// Only helmet for current testing
|
||||
if (helmetObjects.All(belt => belt.armorData.armorType != ArmorType.Helmet)) return;
|
||||
|
||||
// If prefab have any ArmorObject - take it, we will test it
|
||||
if (helmetObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NothingToTest()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f90bbcb767b43bbad0502cc5dfceb6a
|
||||
timeCreated: 1674151599
|
||||
@@ -0,0 +1,169 @@
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using Test.Util;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Objects.Item;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class ItemObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets("t:GameObject").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var itemObjects = gameObject.GetComponentsInChildren<ItemObject>();
|
||||
|
||||
// If prefab have any AbstractObject or any of its children anywhere - take it, we will test it
|
||||
if (itemObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemData_Name()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var itemObject = gameObject.GetComponent<ItemObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
if (itemObject.basicData.finalName.IsNullOrWhitespace())
|
||||
Debug.LogWarning($"Name is not defined: {prefabPathHyperlink}", itemObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemData_Icon()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var itemObject = gameObject.GetComponent<ItemObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
if (!itemObject.basicData.image)
|
||||
Debug.LogError($"{itemObject.name}'s icon is empty: {prefabPathHyperlink}", itemObject);
|
||||
|
||||
if (itemObject.basicData.image.width != itemObject.basicData.image.height)
|
||||
Debug.LogWarning($"{itemObject.name}'s icon size proportions are invalid (width != height): {prefabPathHyperlink}", itemObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemData_Description()
|
||||
{
|
||||
// Nothing here
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemData_Weight()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var itemObject = gameObject.GetComponent<ItemObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
if (itemObject.itemData.weight < 0f)
|
||||
Debug.LogError($"{itemObject.basicData.finalName}'s weight is lesser than 0: {prefabPathHyperlink}", itemObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemData_Quality()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var itemObject = gameObject.GetComponent<ItemObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
if (!itemObject.itemData.quality)
|
||||
Debug.LogError($"{itemObject.basicData.finalName}'s quality is not selected: {prefabPathHyperlink}", itemObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemData_Value()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var itemObject = gameObject.GetComponent<ItemObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
if (itemObject.itemData.value < 0f)
|
||||
Debug.LogError($"{itemObject.basicData.finalName}'s weight is lesser than 0: {prefabPathHyperlink}",
|
||||
itemObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemData_Stackable()
|
||||
{
|
||||
// Nothing
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemData_StackSize()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var itemObject = gameObject.GetComponent<ItemObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
if (itemObject.itemData.stackSize < 1)
|
||||
Debug.LogError($"{itemObject.basicData.finalName}'s stack size is lesser than 1: {prefabPathHyperlink}",
|
||||
itemObject);
|
||||
|
||||
if (!itemObject.itemData.stackable && itemObject.itemData.stackSize != 1)
|
||||
Debug.LogError($"{itemObject.basicData.finalName} is not stackable, stack size must be 1: {prefabPathHyperlink}",
|
||||
itemObject);
|
||||
|
||||
if (itemObject.itemData.stackSize > itemObject.itemData.stackSizeMax)
|
||||
Debug.LogError($"{itemObject.basicData.finalName}'s stack size is greater than max stack size: {prefabPathHyperlink}",
|
||||
itemObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemData_StackSizeMax()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var itemObject = gameObject.GetComponent<ItemObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
if (itemObject.itemData.stackSizeMax < 1)
|
||||
Debug.LogError($"{itemObject.basicData.finalName}'s max stack size is lesser than 1: {prefabPathHyperlink}",
|
||||
itemObject);
|
||||
|
||||
if (!itemObject.itemData.stackable && itemObject.itemData.stackSizeMax != 1)
|
||||
Debug.LogError($"{itemObject.basicData.finalName} is not stackable, stack size must be 1: {prefabPathHyperlink}",
|
||||
itemObject);
|
||||
|
||||
if (itemObject.itemData.stackSize > itemObject.itemData.stackSizeMax)
|
||||
Debug.LogError($"{itemObject.basicData.finalName}'s stack size is greater than max stack size: {prefabPathHyperlink}",
|
||||
itemObject);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65c7e7e6cff54e26b503eba39d91f321
|
||||
timeCreated: 1674058705
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Accessory;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class NecklaceObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets($"t:{nameof(GameObject)}").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var necklaceObjects = gameObject.GetComponentsInChildren<AccessoryObject>();
|
||||
|
||||
// Only necklace for current testing
|
||||
if (necklaceObjects.All(necklace => necklace.accessoryData.accessoryType != AccessoryType.Necklace)) return;
|
||||
|
||||
// If prefab have any AccessoryObject - take it, we will test it
|
||||
if (necklaceObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NothingToTest()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8cc00811ed1143898db4b55b5335ccb1
|
||||
timeCreated: 1674151615
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Armor;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class PantsObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets($"t:{nameof(GameObject)}").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var pantsObjects = gameObject.GetComponentsInChildren<ArmorObject>();
|
||||
|
||||
// Only pants for current testing
|
||||
if (pantsObjects.All(belt => belt.armorData.armorType != ArmorType.Pants)) return;
|
||||
|
||||
// If prefab have any ArmorObject - take it, we will test it
|
||||
if (pantsObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NothingToTest()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bb172e9f8af4432b90b81ea410fdf65
|
||||
timeCreated: 1674151632
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Accessory;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class RingObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets($"t:{nameof(GameObject)}").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var ringObjects = gameObject.GetComponentsInChildren<AccessoryObject>();
|
||||
|
||||
// Only rings for current testing
|
||||
if (ringObjects.All(ring => ring.accessoryData.accessoryType != AccessoryType.Ring)) return;
|
||||
|
||||
// If prefab have any AccessoryObject - take it, we will test it
|
||||
if (ringObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NothingToTest()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c22e4f03a7524d9b97a88644376d3c98
|
||||
timeCreated: 1674151648
|
||||
@@ -0,0 +1,286 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using Test.Util;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Accessory;
|
||||
using VOID.Generic.Objects.Armor;
|
||||
using VOID.Generic.Objects.Item;
|
||||
using VOID.Generic.Objects.Unit;
|
||||
using VOID.Generic.Objects.Unit.Animations;
|
||||
using VOID.Generic.Objects.Unit.Equipment;
|
||||
using VOID.Generic.Objects.Weapon;
|
||||
using VOID.Generic.Objects.Wearable;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class UnitObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets($"t:{nameof(GameObject)}").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var unitObjects = gameObject.GetComponentsInChildren<UnitObject>();
|
||||
|
||||
// If prefab have any ArmorObject - take it, we will test it
|
||||
if (unitObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitData_Portrait()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var unitObject = gameObject.GetComponent<UnitObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
if (!unitObject.basicData.image)
|
||||
Debug.LogError($"{nameof(UnitObject)}'s portrait is not selected: {prefabPathHyperlink}", unitObject);
|
||||
|
||||
if (unitObject.basicData.image.width > unitObject.basicData.image.height)
|
||||
Debug.LogWarning($"{nameof(UnitObject)}'s portrait size proportions are invalid (width > height): {prefabPathHyperlink}");
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitData_Resources()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var unitObject = gameObject.GetComponent<UnitObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
var currentResources = unitObject.unitData.currentResources;
|
||||
var baseMaxResources = unitObject.unitData.baseMaxResources;
|
||||
|
||||
Enum.GetValues(typeof(UnitResourceType))
|
||||
.Cast<UnitResourceType>()
|
||||
.Where(resourceType => currentResources.Get(resourceType) > baseMaxResources.Get(resourceType))
|
||||
.ForEach(resourceType => Debug.LogError($"{nameof(UnitObject)}'s {resourceType} current value is greater than base max: {prefabPathHyperlink}", unitObject));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitData_MainAttributes()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var unitObject = gameObject.GetComponent<UnitObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
var baseMainAttributes = unitObject.unitData.baseMainAttributes;
|
||||
|
||||
Enum.GetValues(typeof(MainAttributeType))
|
||||
.Cast<MainAttributeType>()
|
||||
.Where(mainAttributeType => baseMainAttributes.Get(mainAttributeType) < 1)
|
||||
.ForEach(mainAttributeType => Debug.LogError($"{nameof(UnitObject)}'s {mainAttributeType} is lesser than 1: {prefabPathHyperlink}", unitObject));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitData_SubAttributes()
|
||||
{
|
||||
// Nothing to test
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitData_Ranges()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var unitObject = gameObject.GetComponent<UnitObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
var useRange = unitObject.unitData.useRange;
|
||||
var talkRange = unitObject.unitData.talkRange;
|
||||
var takeRange = unitObject.unitData.takeRange;
|
||||
var inspectRange = unitObject.unitData.inspectRange;
|
||||
|
||||
if (useRange < 1)
|
||||
Debug.LogError($"{nameof(UnitObject)}'s use range is lesser than 1: {prefabPathHyperlink}", unitObject);
|
||||
|
||||
if (talkRange < 1)
|
||||
Debug.LogError($"{nameof(UnitObject)}'s talk range is lesser than 1: {prefabPathHyperlink}", unitObject);
|
||||
|
||||
if (takeRange < 1)
|
||||
Debug.LogError($"{nameof(UnitObject)}'s take range is lesser than 1: {prefabPathHyperlink}", unitObject);
|
||||
|
||||
if (inspectRange < 1)
|
||||
Debug.LogError($"{nameof(UnitObject)}'s inspect range is lesser than 1: {prefabPathHyperlink}", unitObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitData_CastPosition()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var unitObject = gameObject.GetComponent<UnitObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
var castPosition = unitObject.unitData.castPosition;
|
||||
|
||||
if (!castPosition)
|
||||
Debug.LogError($"{nameof(UnitObject)}'s cast position is not selected: {prefabPathHyperlink}", unitObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitAnimator_Events()
|
||||
{
|
||||
// Nothing to test
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitAnimator_ActionQueue()
|
||||
{
|
||||
// Nothing to test
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitAnimator_Animator()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var unitObject = gameObject.GetComponent<UnitObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
var animator = SerializedUtil.GetProperty<Animator>(unitObject, "unitAnimator.animator");
|
||||
if (!animator)
|
||||
Debug.LogError($"{nameof(UnitObject)}'s {nameof(UnitObjectAnimator)} have missing {nameof(Animator)}: {prefabPathHyperlink}", unitObject);
|
||||
|
||||
var animatorCallbacks = SerializedUtil.GetProperty<UnitAnimatorCallbacks>(unitObject, "unitAnimator.unitAnimatorCallbacks");
|
||||
if (!animatorCallbacks)
|
||||
Debug.LogError($"{nameof(UnitObject)}'s {nameof(UnitObjectAnimator)} have missing {nameof(UnitAnimatorCallbacks)}: {prefabPathHyperlink}", unitObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitNavMeshAgent_NavMeshAgent()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var unitObject = gameObject.GetComponent<UnitObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
var navMeshAgent = SerializedUtil.GetProperty<NavMeshAgent>(unitObject, "unitNavMeshAgent.navMeshAgent");
|
||||
if (navMeshAgent == null)
|
||||
Debug.LogError($"{nameof(UnitObject)}'s {nameof(UnitObjectNavAgent)} have missing {nameof(NavMeshAgent)}: {prefabPathHyperlink}", unitObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitDataCalculator_Formulas_TODO()
|
||||
{
|
||||
// TODO: dodać testy
|
||||
Debug.LogWarning("TODO: zrobić weryfikacje formuł");
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitBackpack_PredefinedItems()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var unitObject = gameObject.GetComponent<UnitObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
var itemPrefabs =
|
||||
SerializedUtil.GetPropertyArray<GameObject>(unitObject, "unitBackpack.gameObjectItems");
|
||||
|
||||
itemPrefabs.ForEach(prefab =>
|
||||
{
|
||||
if (!prefab) return;
|
||||
var itemObject = prefab.GetComponent<ItemObject>();
|
||||
if (!itemObject)
|
||||
Debug.LogError(
|
||||
$"{nameof(UnitObject)}'s backpack: prefab '{prefab.name}' is not an {nameof(ItemObject)}: {prefabPathHyperlink}",
|
||||
unitObject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitEquipment_PredefinedWearables()
|
||||
{
|
||||
var canWearInSlot = new Dictionary<EquipmentSlotType, Func<WearableObject, bool>>
|
||||
{
|
||||
[EquipmentSlotType.MainHand] = wearable => wearable is WeaponObject,
|
||||
[EquipmentSlotType.OffHand] = wearable => wearable is WeaponObject,
|
||||
[EquipmentSlotType.Helmet] = wearable => wearable is ArmorObject helmet && helmet.armorData.armorType == ArmorType.Helmet,
|
||||
[EquipmentSlotType.Armor] = wearable => wearable is ArmorObject armor && armor.armorData.armorType == ArmorType.Armor,
|
||||
[EquipmentSlotType.Pants] = wearable => wearable is ArmorObject pants && pants.armorData.armorType == ArmorType.Pants,
|
||||
[EquipmentSlotType.Belt] = wearable => wearable is ArmorObject belt && belt.armorData.armorType == ArmorType.Belt,
|
||||
[EquipmentSlotType.Boots] = wearable => wearable is ArmorObject boots && boots.armorData.armorType == ArmorType.Boots,
|
||||
[EquipmentSlotType.Gloves] = wearable => wearable is ArmorObject gloves && gloves.armorData.armorType == ArmorType.Gloves,
|
||||
[EquipmentSlotType.Necklace] = wearable => wearable is AccessoryObject necklace && necklace.accessoryData.accessoryType == AccessoryType.Necklace,
|
||||
[EquipmentSlotType.RingOne] = wearable => wearable is AccessoryObject ring && ring.accessoryData.accessoryType == AccessoryType.Ring,
|
||||
[EquipmentSlotType.RingTwo] = wearable => wearable is AccessoryObject ring && ring.accessoryData.accessoryType == AccessoryType.Ring,
|
||||
};
|
||||
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var unitObject = gameObject.GetComponent<UnitObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
Enum.GetValues(typeof(EquipmentSlotType))
|
||||
.Cast<EquipmentSlotType>()
|
||||
.ForEach(equipmentSlotType =>
|
||||
{
|
||||
var equipmentSlotName = equipmentSlotType.ToString()[..1].ToLower() + equipmentSlotType.ToString()[1..];
|
||||
var equippedItem = SerializedUtil.GetProperty<EquippedItem>(unitObject, $"unitEquipment.{equipmentSlotName}");
|
||||
if (equippedItem == null || !equippedItem.gameObject) return;
|
||||
var wearableObject = equippedItem.gameObject.GetComponent<WearableObject>();
|
||||
var canBePlaced = canWearInSlot.GetValueOrDefault(equipmentSlotType).Invoke(wearableObject);
|
||||
if (!wearableObject || !canBePlaced)
|
||||
Debug.LogError(
|
||||
$"{nameof(UnitObject)}'s equipment: prefab '{equippedItem.gameObject.name}' can't be placed in {equipmentSlotName}: {prefabPathHyperlink}",
|
||||
unitObject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitAbilityBook_DefaultAttackAbility()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var unitObject = gameObject.GetComponent<UnitObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
var defaultAttack = unitObject.unitAbilityBook.defaultAttackAbility;
|
||||
|
||||
if (defaultAttack == null)
|
||||
Debug.LogError(
|
||||
$"{nameof(UnitObject)}'s ability book: default attack ability is not selected: {prefabPathHyperlink}",
|
||||
unitObject);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7f593713e8e4f659f0ccdfed05458ec
|
||||
timeCreated: 1667237323
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using Test.Util;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Objects.Weapon;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class WeaponObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets($"t:{nameof(GameObject)}").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var weaponObjects = gameObject.GetComponentsInChildren<WeaponObject>();
|
||||
|
||||
// If prefab have any ArmorObject - take it, we will test it
|
||||
if (weaponObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WeaponData_Damage()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var weaponObject = gameObject.GetComponent<WeaponObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
var damageMin = weaponObject.weaponData.damageMin;
|
||||
var damageMax = weaponObject.weaponData.damageMax;
|
||||
|
||||
if (damageMin < 0f)
|
||||
Debug.LogError($"{nameof(WeaponObject)}'s damage min is lesser than 0: {prefabPathHyperlink}", weaponObject);
|
||||
|
||||
if (damageMax < 0f)
|
||||
Debug.LogError($"{nameof(WeaponObject)}'s damage max is lesser than 0: {prefabPathHyperlink}", weaponObject);
|
||||
|
||||
if (damageMin > damageMax)
|
||||
Debug.LogError($"{nameof(WeaponObject)}'s damage min is greater than damage max: {prefabPathHyperlink}", weaponObject);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WeaponData_AttackAbility()
|
||||
{
|
||||
_gameObjects.ForEach(gameObject =>
|
||||
{
|
||||
var weaponObject = gameObject.GetComponent<WeaponObject>();
|
||||
var prefabPath = AssetDatabase.GetAssetPath(gameObject.GetInstanceID());
|
||||
var prefabPathHyperlink = DebugLogUtil.Hyperlink(prefabPath);
|
||||
|
||||
if (!weaponObject.weaponData.attackAbility)
|
||||
Debug.LogError($"{nameof(WeaponObject)}'s attack ability is not selected: {prefabPathHyperlink}", weaponObject);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc86a94d193047359f9db0b45ef4a80e
|
||||
timeCreated: 1674149184
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Objects.Wearable;
|
||||
|
||||
namespace Test.EditMode.Prefabs.Generic
|
||||
{
|
||||
public class WearableObjectTest
|
||||
{
|
||||
private List<GameObject> _gameObjects = new();
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
AssetDatabase.FindAssets($"t:{nameof(GameObject)}").ForEach(gameObjectGuid =>
|
||||
{
|
||||
var gameObjectPath = AssetDatabase.GUIDToAssetPath(gameObjectGuid);
|
||||
var gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(gameObjectPath);
|
||||
var wearableObjects = gameObject.GetComponentsInChildren<WearableObject>();
|
||||
|
||||
// If prefab have any ArmorObject - take it, we will test it
|
||||
if (wearableObjects.Length > 0) _gameObjects.Add(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
_gameObjects?.Clear();
|
||||
_gameObjects = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NothingToTest()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63cff3c64e0b4c4bbc9c74195d75c987
|
||||
timeCreated: 1674147321
|
||||
Reference in New Issue
Block a user