Example #1
0
            public IEnumerator QueryUserEntitlement_Success()
            {
                Entitlement entitlements = AccelBytePlugin.GetEntitlements();
                Result <EntitlementPagingSlicedResult> getPagedEntitlementsResult = null;

                entitlements.QueryUserEntitlements("", "", 0, 20, result => { getPagedEntitlementsResult = result; });

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

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getPagedEntitlementsResult.IsError, "Get user entitlements failed.");
                expectedEntitlementId = getPagedEntitlementsResult.Value.data[0].id;
            }
Example #2
0
            public IEnumerator GrantUserEntitlement_Success()
            {
                Entitlement entitlements = AccelBytePlugin.GetEntitlements();
                Result <EntitlementPagingSlicedResult> getEmptyPagedEntitlementsResult = null;

                entitlements.QueryUserEntitlements("", TestVariables.inGameItem.itemId, 0, 20, result => { getEmptyPagedEntitlementsResult = result; });

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

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getEmptyPagedEntitlementsResult.IsError, "Get user entitlements failed.");

                GrantUserEntitlementRequest grantUserEntitlementRequest = new GrantUserEntitlementRequest
                {
                    itemId        = TestVariables.inGameItem.itemId,
                    itemNamespace = TestVariables.inGameItem.Namespace,
                    grantedCode   = "123456789",
                    quantity      = 1,
                    source        = EntitlementSource.ACHIEVEMENT,
                    region        = TestVariables.region,
                    language      = TestVariables.language
                };

                GrantUserEntitlementRequest[] grantUserEntitlementsRequest = { grantUserEntitlementRequest };

                ServerEcommerce serverEcommerce = AccelByteServerPlugin.GetEcommerce();

                Result <StackableEntitlementInfo[]> stackableEntitlementInfo = null;

                serverEcommerce.GrantUserEntitlement(TestVariables.userId, grantUserEntitlementsRequest, result => { stackableEntitlementInfo = result; });

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

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!stackableEntitlementInfo.IsError, "Grant user entitlement failed.");
                TestHelper.Assert.IsTrue(stackableEntitlementInfo.Value[0].itemId == TestVariables.inGameItem.itemId, "Item is not found.");

                Result <EntitlementPagingSlicedResult> getPagedEntitlementsResult = null;

                entitlements.QueryUserEntitlements("", TestVariables.inGameItem.itemId, 0, 20, result => { getPagedEntitlementsResult = result; });

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

                    yield return(null);
                }

                bool grantedEntitlementFound = false;

                for (int i = 0; i < getPagedEntitlementsResult.Value.data.Length; i++)
                {
                    if (getPagedEntitlementsResult.Value.data[i].grantedCode == grantUserEntitlementRequest.grantedCode)
                    {
                        grantedEntitlementFound = true;
                    }
                }

                TestHelper.Assert.IsTrue(!getPagedEntitlementsResult.IsError, "Get user entitlements failed.");
                TestHelper.Assert.IsTrue(grantedEntitlementFound, "Granted Item is not found.");
            }