Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class InventoryPickUpTest : MonoBehaviour
- {
- public Item Item1;
- public Item Item2;
- private Inventory _inv;
- private bool _passed = true;
- public void Start()
- {
- _inv = GetComponent<Inventory>();
- if (_inv.GetDifferentItemsCount() != 0)
- {
- fail("Inventory not empty at start.");
- }
- if (_inv.GetItemCount(Item1) != 0)
- {
- fail("Item that was not added to inventory was found in inventory.");
- }
- _inv.AddItem(Item1);
- if (Item1.transform.parent != this.transform)
- {
- fail("First added item was not made a child of the inventory.");
- }
- if (Item1.gameObject.activeSelf)
- {
- fail("First added item was still active after being added.");
- }
- if (_inv.GetItemCount(Item1) != 1)
- {
- fail("GetItemCount for added item was not 1.");
- }
- _inv.AddItem(Item2);
- if (_inv.GetDifferentItemsCount() != 1)
- {
- fail("Diff item count in inventory != 1.");
- }
- }
- public void Update()
- {
- if (Item2 != null)
- {
- fail("Second identical item added was not destroyed at the time of addition.");
- }
- endTest();
- }
- private void fail(string reason)
- {
- print("FAIL:" + reason);
- _passed = false;
- }
- private void endTest()
- {
- if (_passed)
- {
- IntegrationTest.Pass(this.gameObject);
- }
- else
- {
- IntegrationTest.Fail(this.gameObject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment