Пример #1
0
        public IEnumerator InventoryViewUpdateItemListAfterPurchase()
        {
            yield return(null);

            //Find inventory view, set active to be sure, find script on GO
            GameObject inventoryView = GameObject.Find("InventoryGridView");

            inventoryView.SetActive(true);
            ShopGridView inventoryGrid = inventoryView.GetComponent <ShopGridView>();

            //Store itemCount before trying to add an item to the grid
            int itemCountBefore = inventoryGrid.GetGridItemListCount();

            //Perform buying operation
            ShopCreator.Instance.shopModel.ConfirmTransactionSelectedItem(ShopActions.PURCHASED);

            //Update icon view, should be with the bought item
            inventoryGrid.RepopulateItemIconView();

            //Store the new item count
            int itemCountAfter = inventoryGrid.GetGridItemListCount();

            //Execute assert
            Assert.That(itemCountAfter, Is.EqualTo(itemCountBefore + 1));
        }
Пример #2
0
        public IEnumerator SetupTests()
        {
            yield return
                (null); //yield return null skips one frame, this is to make sure that this happens after the scene is loaded

            //The shop scene only contains one grid buy view, we use Resources.FindObjectsOfTypeAll to get the reference to it,
            //Resources.FFindObjectsOfTypeAll is used instead of GameObject.Find because the later can't find disabled objects
            gridView = Resources.FindObjectsOfTypeAll <ShopGridView>()[0];

            //Active the gridView game object to initialize the class, if we don't do this 'void Start()' won't be called
            //You should active all the game objects that are involved in the test before testing the functions from their components
            gridView.gameObject.SetActive(true);
        }
Пример #3
0
        public IEnumerator ShopViewUpdateItemListAfterSell()
        {
            yield return(null);

            //Find the InventoryGridView GameObject & ShopGridView component.
            ShopGridView gridView = GameObject.Find("InventoryGridView").GetComponent <ShopGridView>();

            //Store the ListCount before performing any altering actions
            int countBeforeTransaction = gridView.GetGridItemListCount();

            //Pass on correct Shop Action parameter to Inventory Model (which has the "selling" functionality)
            ShopCreator.Instance.inventoryModel.ConfirmTransactionSelectedItem(ShopActions.SOLD);

            //Store the ListCount after performing the ListCount-altering action.
            int countAfterTransaction = gridView.GetGridItemListCount();

            //Compare the 2 ListCounts, saying that 2nd ListCount is 1 less than the 1st.
            Assert.That(countAfterTransaction, Is.EqualTo(countBeforeTransaction - 1));
        }
Пример #4
0
        public IEnumerator ShopViewUpdateItemListAfterPurchase()
        {
            yield return(null);

            //Find the ShopGridView GameObject & component.
            ShopGridView gridView = GameObject.Find("ShopGridView").GetComponent <ShopGridView>();

            //Store the ListCount before performing any altering actions
            int countBefore = gridView.GetGridItemListCount();

            //Pass on correct Shop Action parameter
            ShopCreator.Instance.shopModel.ConfirmTransactionSelectedItem(ShopActions.PURCHASED);

            //Store the ListCount after performing the ListCount-altering action.
            int countAfter = gridView.GetGridItemListCount();

            //Compare the 2 ListCounts, saying that 2nd ListCount is 1 less than the 1st.
            Assert.That(countAfter, Is.EqualTo(countBefore - 1));
        }