Beispiel #1
0
            public IEnumerator GetItemByCriteria_byTags_Success()
            {
                Items items = AccelBytePlugin.GetItems();

                string[]     tags         = new string[] { "SDK", "GAME" };
                ItemCriteria itemCriteria = new ItemCriteria {
                    tags = tags
                };
                Result <ItemPagingSlicedResult> getItemByCriteriaResult = null;

                items.GetItemsByCriteria(
                    itemCriteria,
                    result => { getItemByCriteriaResult = result; });

                while (getItemByCriteriaResult == null)
                {
                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getItemByCriteriaResult.IsError, "Get item by item by tags failed.");
                if (getItemByCriteriaResult.Value.data.Length > 0)
                {
                    TestHelper.Assert.IsTrue(
                        getItemByCriteriaResult.Value.data[0].tags[0] == tags[0] ||
                        getItemByCriteriaResult.Value.data[0].tags[0] == tags[1],
                        "Get item by item by tags failed.");
                }
            }
Beispiel #2
0
            public IEnumerator GetItemByCriteria_CategoryPathInvalid_SuccessButEmpty()
            {
                Items        items = AccelBytePlugin.GetItems();
                const string invalidCategoryPath = "/invalidPath";
                Result <ItemPagingSlicedResult> getItemByCriteriaResult = null;
                ItemCriteria itemCriteria = new ItemCriteria {
                    categoryPath = invalidCategoryPath
                };

                items.GetItemsByCriteria(
                    itemCriteria,
                    result => { getItemByCriteriaResult = result; });

                while (getItemByCriteriaResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getItemByCriteriaResult.IsError, "Get item by invalid category path failed.");
                TestHelper.Assert.IsTrue(
                    getItemByCriteriaResult.Value.data.Length == 0,
                    "Get item by invalid category path failed.");
            }
Beispiel #3
0
            public IEnumerator GetItemByCriteria_LanguageInvalid_Success()
            {
                Items        items = AccelBytePlugin.GetItems();
                const string invalidCategoryLanguage = "id";
                ItemCriteria itemCriteria            = new ItemCriteria {
                    categoryPath = TestVariables.expectedChildCategoryPath,
                    language     = invalidCategoryLanguage
                };
                Result <ItemPagingSlicedResult> getItemByCriteriaResult = null;

                items.GetItemsByCriteria(
                    itemCriteria,
                    result => { getItemByCriteriaResult = result; });

                while (getItemByCriteriaResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getItemByCriteriaResult.IsError, "Get item by invalid language failed.");
                TestHelper.Assert.IsTrue(
                    getItemByCriteriaResult.Value.data[0].categoryPath.Contains(TestVariables.expectedChildCategoryPath),
                    "Get item by invalid language failed.");
            }
Beispiel #4
0
            public IEnumerator GetUserOrder_OrderExists_Success()
            {
                Items        items        = AccelBytePlugin.GetItems();
                ItemCriteria itemCriteria = new ItemCriteria
                {
                    categoryPath = TestVariables.expectedChildCategoryPath,
                    sortBy       = "createdAt:desc"
                };
                Result <ItemPagingSlicedResult> getItemsByCriteria = null;

                items.GetItemsByCriteria(
                    itemCriteria,
                    result =>
                {
                    getItemsByCriteria = result;
                });

                while (getItemsByCriteria == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                int          quantity     = 1;
                Orders       orders       = AccelBytePlugin.GetOrders();
                OrderRequest orderRequest = new OrderRequest
                {
                    currencyCode    = getItemsByCriteria.Value.data[0].regionData[0].currencyCode,
                    discountedPrice = getItemsByCriteria.Value.data[0].regionData[0].discountedPrice * quantity,
                    itemId          = getItemsByCriteria.Value.data[0].itemId,
                    price           = getItemsByCriteria.Value.data[0].regionData[0].price * quantity,
                    quantity        = quantity,
                    returnUrl       = "https://www.example.com"
                };
                Result <OrderInfo> createOrderResult = null;

                orders.CreateOrder(orderRequest, result => { createOrderResult = result; });

                while (createOrderResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                Result <OrderInfo> getUserOrderResult = null;

                orders.GetUserOrder(createOrderResult.Value.orderNo, result => { getUserOrderResult = result; });

                while (getUserOrderResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getUserOrderResult.IsError, "Get user order failed.");
            }
Beispiel #5
0
            public IEnumerator GetItem_ItemLanguageEmpty_Fail()
            {
                Items items = AccelBytePlugin.GetItems();
                Result <PopulatedItemInfo> getItemResult = null;

                items.GetItemById(this.expectedItemId, TestVariables.region, "", result => { getItemResult = result; });

                while (getItemResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(getItemResult.IsError, "Get item with empty language not failed.");
            }
Beispiel #6
0
            public IEnumerator SetUp_ExpectedEcommerceStuff()
            {
                Items      items      = AccelBytePlugin.GetItems();
                Categories categories = AccelBytePlugin.GetCategories();
                Result <ItemPagingSlicedResult> getItemResult          = null;
                Result <CategoryInfo[]>         getChildCategoryResult = null;
                ItemCriteria itemCriteria = new ItemCriteria
                {
                    categoryPath = TestVariables.expectedChildCategoryPath,
                    region       = TestVariables.region,
                    language     = TestVariables.language
                };

                items.GetItemsByCriteria(
                    itemCriteria,
                    result =>
                {
                    getItemResult       = result;
                    this.expectedItemId = result.Value.data[0].itemId;
                });

                while (getItemResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                categories.GetChildCategories(
                    TestVariables.expectedChildCategoryPath,
                    TestVariables.language,
                    result => { getChildCategoryResult = result; });

                while (getChildCategoryResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                Assert.That(!getItemResult.IsError);
                Assert.That(!getChildCategoryResult.IsError);
            }
Beispiel #7
0
            public IEnumerator GetItemByCriteria_ItemTypeBUNDLE_Success()
            {
                Items        items        = AccelBytePlugin.GetItems();
                ItemCriteria itemCriteria = new ItemCriteria {
                    itemType = ItemType.BUNDLE
                };
                Result <ItemPagingSlicedResult> getItemByCriteriaResult = null;

                items.GetItemsByCriteria(
                    itemCriteria,
                    result => { getItemByCriteriaResult = result; });

                while (getItemByCriteriaResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getItemByCriteriaResult.IsError, "Get item by item type BUNDLE failed.");
            }
Beispiel #8
0
            public IEnumerator GetItemByCriteria_LanguageEmpty_Success()
            {
                Items        items        = AccelBytePlugin.GetItems();
                ItemCriteria itemCriteria = new ItemCriteria {
                    categoryPath = TestVariables.expectedChildCategoryPath,
                    language     = ""
                };
                Result <ItemPagingSlicedResult> getItemByCriteriaResult = null;

                items.GetItemsByCriteria(
                    itemCriteria,
                    result => { getItemByCriteriaResult = result; });

                while (getItemByCriteriaResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(getItemByCriteriaResult.IsError, "Get item by empty language not failed.");
            }
Beispiel #9
0
            public IEnumerator GetItemByCriteria_CategoryPathUnspecified_Success()
            {
                Items        items        = AccelBytePlugin.GetItems();
                ItemCriteria itemCriteria = new ItemCriteria();
                Result <ItemPagingSlicedResult> getItemByCriteriaResult = null;

                items.GetItemsByCriteria(
                    itemCriteria,
                    result => { getItemByCriteriaResult = result; });

                while (getItemByCriteriaResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getItemByCriteriaResult.IsError, "Get item by valid criteria failed.");
                TestHelper.Assert.IsTrue(
                    getItemByCriteriaResult.Value.data.Length > 0,
                    "Get item by valid criteria failed.");
            }
Beispiel #10
0
            public IEnumerator GetItem_ItemRegionInvalid_Success()
            {
                Items items = AccelBytePlugin.GetItems();
                Result <PopulatedItemInfo> getItemResult = null;
                const string invalidItemRegion           = "ID";

                items.GetItemById(
                    this.expectedItemId,
                    invalidItemRegion,
                    TestVariables.language,
                    result => { getItemResult = result; });

                while (getItemResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getItemResult.IsError, "Get item failed with invalid region failed.");
                TestHelper.Assert.That(getItemResult.Value, Is.Not.Null, "Get item failed with invalid region failed.");
            }
Beispiel #11
0
            public IEnumerator GetItem_ItemValid_Success()
            {
                Items items = AccelBytePlugin.GetItems();
                Result <PopulatedItemInfo> getItemResult = null;

                items.GetItemById(
                    this.expectedItemId,
                    TestVariables.region,
                    TestVariables.language,
                    result => { getItemResult = result; });

                while (getItemResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getItemResult.IsError, "Get item failed.");
                TestHelper.Assert.IsTrue(
                    getItemResult.Value.categoryPath.Contains(this.expectedCategoryName),
                    "Get item failed.");
            }
Beispiel #12
0
            public IEnumerator GetItemByCriteria_AppTypeGAME_Success()
            {
                Items        items        = AccelBytePlugin.GetItems();
                ItemCriteria itemCriteria = new ItemCriteria {
                    appType = EntitlementAppType.GAME
                };
                Result <ItemPagingSlicedResult> getItemByCriteriaResult = null;

                items.GetItemsByCriteria(
                    itemCriteria,
                    result => { getItemByCriteriaResult = result; });

                while (getItemByCriteriaResult == null)
                {
                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getItemByCriteriaResult.IsError, "Get item by item appType GAME failed.");
                if (getItemByCriteriaResult.Value.data.Length > 0)
                {
                    TestHelper.Assert.IsTrue(getItemByCriteriaResult.Value.data[0].appType == EntitlementAppType.GAME, "Get item by item appType GAME failed.");
                }
            }
Beispiel #13
0
            public IEnumerator GetItem_ItemIdEmpty_ItemNotFound()
            {
                Items items = AccelBytePlugin.GetItems();
                Result <PopulatedItemInfo> getItemResult = null;

                items.GetItemById(
                    "",
                    TestVariables.region,
                    TestVariables.language,
                    result => { getItemResult = result; });

                while (getItemResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(getItemResult.IsError, "Request error on get item failed.");
                TestHelper.Assert.IsTrue(
                    getItemResult.Error.Code.Equals(ErrorCode.NotFound),
                    "Request error on get get item failed.");
            }