예제 #1
0
 /// <summary>
 /// Use this for initialization
 /// </summary>
 void Start()
 {
     AssignSceneComponents();
     user            = AccelBytePlugin.GetUser();
     entitlements    = AccelBytePlugin.GetEntitlements();
     entitlementList = new List <PagedEntitlements>();
     pageNow         = 0;
     pageSize        = 18;
     entitlements.GetUserEntitlements(pageNow, pageSize, OnGetUserEntitlements);
 }
예제 #2
0
            public IEnumerator GetUserEntitlementById_Failed()
            {
                Entitlement entitlements = AccelBytePlugin.GetEntitlements();

                Result <EntitlementInfo> entitlementInfo = null;

                entitlements.GetUserEntitlementById("Invalid", result => { entitlementInfo = result; });

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

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(entitlementInfo.IsError, "Get user entitlement by invalid id is success.");
            }
예제 #3
0
            public IEnumerator ConsumeUserEntitlementZero_Failed()
            {
                Entitlement entitlements = AccelBytePlugin.GetEntitlements();

                Result <EntitlementInfo> getEntitlementInfoResult = null;

                entitlements.ConsumeUserEntitlement(expectedEntitlementId, 0, result => { getEntitlementInfoResult = result; });

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

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(getEntitlementInfoResult.IsError, "Consume user entitlement success.");
            }
예제 #4
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;
            }
예제 #5
0
            public IEnumerator GetUserEntitlementById_Success()
            {
                Entitlement entitlements = AccelBytePlugin.GetEntitlements();

                Result <EntitlementInfo> entitlementInfo = null;

                entitlements.GetUserEntitlementById(expectedEntitlementId, result => { entitlementInfo = result; });

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

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!entitlementInfo.IsError, "Get user entitlement by id failed.");
                TestHelper.Assert.IsTrue(entitlementInfo.Value.id == expectedEntitlementId, "Expected entitlement is not found.");
            }
예제 #6
0
            public IEnumerator ConsumeUserEntitlement_Success()
            {
                Entitlement entitlements = AccelBytePlugin.GetEntitlements();

                Result <EntitlementInfo> getEntitlementInfoResult = null;

                entitlements.ConsumeUserEntitlement(expectedEntitlementId, 1, result => { getEntitlementInfoResult = result; });

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

                    yield return(null);
                }

                bool bConsumeUserEntitlement = (getEntitlementInfoResult.Value.status == EntitlementStatus.CONSUMED);

                TestHelper.Assert.IsTrue(!getEntitlementInfoResult.IsError, "Consume user entitlement failed.");
                TestHelper.Assert.IsTrue(bConsumeUserEntitlement, "Consume user entitlement failed.");
            }
예제 #7
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.");
            }