Guest User

Untitled

a guest
May 6th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. public class InventoryPickUpTest : MonoBehaviour
  2. {
  3.     public Item Item1;
  4.     public Item Item2;
  5.    
  6.     private Inventory _inv;
  7.     private bool _passed = true;
  8.  
  9.     public void Start()
  10.     {
  11.         _inv = GetComponent<Inventory>();
  12.         if (_inv.GetDifferentItemsCount() != 0)
  13.         {
  14.             fail("Inventory not empty at start.");     
  15.         }
  16.         if (_inv.GetItemCount(Item1) != 0)
  17.         {
  18.             fail("Item that was not added to inventory was found in inventory.");
  19.         }          
  20.         _inv.AddItem(Item1);
  21.         if (Item1.transform.parent != this.transform)
  22.         {
  23.             fail("First added item was not made a child of the inventory.");           
  24.         }
  25.         if (Item1.gameObject.activeSelf)
  26.         {
  27.             fail("First added item was still active after being added.");      
  28.         }
  29.         if (_inv.GetItemCount(Item1) != 1)
  30.         {
  31.             fail("GetItemCount for added item was not 1.");    
  32.         }
  33.         _inv.AddItem(Item2);       
  34.         if (_inv.GetDifferentItemsCount() != 1)
  35.         {
  36.             fail("Diff item count in inventory != 1.");    
  37.         }
  38.     }
  39.  
  40.     public void Update()
  41.     {
  42.         if (Item2 != null)
  43.         {
  44.             fail("Second identical item added was not destroyed at the time of addition.");        
  45.         }  
  46.         endTest(); 
  47.     }
  48.  
  49.     private void fail(string reason)
  50.     {
  51.         print("FAIL:" + reason);
  52.         _passed = false;       
  53.     }
  54.  
  55.     private void endTest()
  56.     {
  57.         if (_passed)
  58.         {
  59.             IntegrationTest.Pass(this.gameObject);
  60.         }
  61.         else
  62.         {
  63.             IntegrationTest.Fail(this.gameObject);
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment