public IEnumerator GetDescendantCategory_CategoryEmpty_Error() { Categories categories = AccelBytePlugin.GetCategories(); Result <CategoryInfo[]> getDescendantCategoryResult = null; categories.GetDescendantCategories( "", TestVariables.language, result => { getDescendantCategoryResult = result; }); while (getDescendantCategoryResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.Assert.IsTrue( getDescendantCategoryResult.IsError, "Get descendant category with empty category failed."); TestHelper.Assert.That( getDescendantCategoryResult.Value, Is.Null, "Get descendant category with empty category not return a data."); }
public IEnumerator GetDescendantCategory_CategoryInvalid_ReturnAnEmptyArray() { Categories categories = AccelBytePlugin.GetCategories(); Result <CategoryInfo[]> getDescendantCategoryResult = null; const string invalidCategory = "invalid"; categories.GetDescendantCategories( invalidCategory, TestVariables.language, result => { getDescendantCategoryResult = result; }); while (getDescendantCategoryResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.Assert.IsTrue( !getDescendantCategoryResult.IsError, "Get descendant category with invalid category failed."); TestHelper.Assert.IsTrue( getDescendantCategoryResult.Value.Length == 0, "Get descendant category with invalid category not return an empty array."); }
public IEnumerator UpdateSlotMetadata_Success() { CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage(); string[] tags = { "newTag1", "newTag2" }; string label = "updatedLabel"; string customMeta = "updatedCustom"; Result <Slot> updateSlotMetadataResult = null; cloudStorage.UpdateSlotMetadata( this.createdSlot.slotId, tags, label, customMeta, result => { updateSlotMetadataResult = result; }); while (updateSlotMetadataResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(updateSlotMetadataResult, "Update slot"); this.updatedSlotMeta = updateSlotMetadataResult.Value; TestHelper.Assert.That(!updateSlotMetadataResult.IsError); }
public IEnumerator GetChildCategory_CategoryEmpty_Error() { Categories categories = AccelBytePlugin.GetCategories(); const string emptyCategoryPath = ""; Result <CategoryInfo[]> getChildCategoryResult = null; categories.GetChildCategories( emptyCategoryPath, TestVariables.language, result => { getChildCategoryResult = result; }); while (getChildCategoryResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.Assert.IsTrue( getChildCategoryResult.IsError, "Get child category with empty path not error."); TestHelper.Assert.That( getChildCategoryResult.Value, Is.Null, "Get child category with empty path return a data."); }
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."); } }
public IEnumerator Setup() { this.user = AccelBytePlugin.GetUser(); if (this.user.Session.IsValid()) { Result logoutResult = null; this.user.Logout(r => logoutResult = r); while (logoutResult == null) { Thread.Sleep(100); yield return(null); } } Result loginWithDevice = null; this.user.LoginWithDeviceId(result => { loginWithDevice = result; }); while (loginWithDevice == null) { Thread.Sleep(100); yield return(null); } Debug.Log(this.user.Session.UserId); Assert.That(!loginWithDevice.IsError); }
private void OutputAuthCode(Sony.NP.Auth.AuthCodeResponse response) { if (response == null) { return; } PrintLog("Auth Code Response"); if (response.Locked == false) { PrintLog("AuthCode : " + response.AuthCode); PrintLog("IssuerId : " + response.IssuerId); var user = AccelBytePlugin.GetUser(); PrintLog("\nLogin to AB"); user.LoginWithOtherPlatform(AccelByte.Models.PlatformType.PS4, response.AuthCode, result => { if (!result.IsError) { PrintLog("\nLogin Success!"); user.GetData(resultData => { if (!resultData.IsError) { PrintLog("\nUserId: " + resultData.Value.userId); PrintLog("\nDisplayName: " + resultData.Value.displayName); } }); } }); } }
public IEnumerator Teardown() { CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage(); Result <Slot[]> getAllSlotResult = null; cloudStorage.GetAllSlots(result => { getAllSlotResult = result; }); while (getAllSlotResult == null) { Thread.Sleep(100); yield return(null); } Debug.Log("get all slot is error: " + getAllSlotResult.IsError); foreach (var slot in getAllSlotResult.Value) { Result deleteResult = null; cloudStorage.DeleteSlot(slot.slotId, result => { deleteResult = result; }); while (deleteResult == null) { Thread.Sleep(100); yield return(null); } Debug.Log("delete 1 slot is error: " + deleteResult.IsError); } }
public IEnumerator UpdateGameProfile_Success() { GameProfiles gameProfiles = AccelBytePlugin.GetGameProfiles(); this.gameProfile.label = "label test"; this.gameProfile.profileName = "profile name test"; Result <GameProfile> updateGameProfileResult = null; gameProfiles.UpdateGameProfile(this.gameProfile, result => { updateGameProfileResult = result; }); while (updateGameProfileResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(updateGameProfileResult, "Update game profile"); TestHelper.Assert.That(!updateGameProfileResult.IsError); var gameProfileResult = updateGameProfileResult.Value; TestHelper.Assert.That(this.gameProfile.label, Is.EqualTo(gameProfileResult.label)); TestHelper.Assert.That(this.gameProfile.profileName, Is.EqualTo(gameProfileResult.profileName)); }
/// <summary> /// When logout button pressed, redirect to LoginPage scene. /// </summary> void OnLogoutClicked() { User user = AccelBytePlugin.GetUser(); user.Logout(); SceneManager.LoadScene(SceneNames.LoginPage.ToString()); }
public IEnumerator GetAllSlots_DoesntContainUpdatedSlot() { CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage(); Result <Slot[]> getAllSlotsResults = null; cloudStorage.GetAllSlots(result => { getAllSlotsResults = result; }); while (getAllSlotsResults == null) { Thread.Sleep(100); yield return(null); } bool updatedSlotNotFound = true; foreach (Slot slot in getAllSlotsResults.Value) { if (slot.slotId == this.createdSlot.slotId) { updatedSlotNotFound = false; } } TestHelper.LogResult(getAllSlotsResults, "Get all slots 3, after deleted"); TestHelper.Assert.That(!getAllSlotsResults.IsError); TestHelper.Assert.That(updatedSlotNotFound, "Slot still exist after deleted!"); }
public IEnumerator CreateOrder_FictionalItem_Error() { Orders orders = AccelBytePlugin.GetOrders(); OrderRequest orderRequest; Result <OrderInfo> createOrderResult = null; orderRequest = new OrderRequest { currencyCode = "JPY", discountedPrice = 5, itemId = "abcde12345", price = 5, quantity = 1, returnUrl = "https://www.example.com" }; orders.CreateOrder(orderRequest, result => { createOrderResult = result; }); while (createOrderResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.Assert.IsTrue(createOrderResult.IsError, "Create an order with a non-existing item failed."); }
public IEnumerator Setup() { var user = AccelBytePlugin.GetUser(); Result loginWithDevice = null; user.LoginWithDeviceId(result => { loginWithDevice = result; }); while (loginWithDevice == null) { Thread.Sleep(100); yield return(null); } Result <UserData> getDataResult = null; user.GetData(r => getDataResult = r); while (getDataResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(getDataResult); TestHelper.Assert.That(getDataResult.IsError, Is.False); TestHelper.Assert.That(!loginWithDevice.IsError); }
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."); }
public IEnumerator GetGameProfileAttribute_Success() { GameProfiles gameProfiles = AccelBytePlugin.GetGameProfiles(); Result <GameProfileAttribute> getGameProfileAttributeResult = null; gameProfiles.GetGameProfileAttribute( this.gameProfile.profileId, "test", result => { getGameProfileAttributeResult = result; }); while (getGameProfileAttributeResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(getGameProfileAttributeResult, "Get game profile attribute"); TestHelper.Assert.That(!getGameProfileAttributeResult.IsError); TestHelper.Assert.That(getGameProfileAttributeResult.Value.name, Is.EqualTo("test")); TestHelper.Assert.That( this.gameProfile.attributes["test"], Is.EqualTo(getGameProfileAttributeResult.Value.value)); }
public IEnumerator UpdateGameProfileAttribute_Success() { GameProfiles gameProfiles = AccelBytePlugin.GetGameProfiles(); Result <GameProfile> updateGameProfileAttributeResult = null; gameProfiles.UpdateGameProfileAttribute( this.gameProfile.profileId, new GameProfileAttribute { name = "test", value = "updated value" }, result => { updateGameProfileAttributeResult = result; }); while (updateGameProfileAttributeResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(updateGameProfileAttributeResult, "Get game profile attribute"); TestHelper.Assert.That(!updateGameProfileAttributeResult.IsError); TestHelper.Assert.That(updateGameProfileAttributeResult.Value.attributes.ContainsKey("test")); TestHelper.Assert.That( updateGameProfileAttributeResult.Value.attributes["test"], Is.EqualTo("updated value")); }
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."); }
public IEnumerator CreateGameProfile_Success() { GameProfiles gameProfiles = AccelBytePlugin.GetGameProfiles(); Result <GameProfile> createGameProfileResult = null; gameProfiles.CreateGameProfile( new GameProfileRequest { label = "GameProfile Test", profileName = "ProfileName Test", tags = new string[] { "tag1", "tag2", "tag3" }, attributes = new Dictionary <string, string>() { { "test", "test123" }, { "name", "testName" } } }, result => { createGameProfileResult = result; }); while (createGameProfileResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(createGameProfileResult, "Create game profile"); Assert.That(!createGameProfileResult.IsError); Assert.NotNull(createGameProfileResult.Value); this.gameProfile = createGameProfileResult.Value; }
public IEnumerator GetAllGameProfile_Success() { GameProfiles gameProfiles = AccelBytePlugin.GetGameProfiles(); Result <GameProfile[]> getAllGameProfilesResults = null; gameProfiles.GetAllGameProfiles(result => { getAllGameProfilesResults = result; }); while (getAllGameProfilesResults == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(getAllGameProfilesResults, "Get all game profiles, after created"); Assert.That(!getAllGameProfilesResults.IsError); bool gameProfileFound = false; foreach (GameProfile gameProfile in getAllGameProfilesResults.Value) { if (gameProfile.profileId == this.gameProfile.profileId) { gameProfileFound = true; break; } } Assert.That(gameProfileFound); }
public IEnumerator GetChildCategory_CategoryValid_LanguageInvalid_Success() { Categories categories = AccelBytePlugin.GetCategories(); const string invalidLanguage = "unknown"; Result <CategoryInfo[]> getChildCategoryResult = null; bool containDogeCoin = false; categories.GetChildCategories( TestVariables.expectedRootCategoryPath, invalidLanguage, result => { getChildCategoryResult = result; }); while (getChildCategoryResult == null) { Thread.Sleep(100); yield return(null); } foreach (CategoryInfo child in getChildCategoryResult.Value) { if (child.categoryPath.Contains(TestVariables.expectedChildCategoryPath)) { containDogeCoin = true; } } TestHelper.Assert.IsTrue( !getChildCategoryResult.IsError, "Get child category with invalid language failed."); TestHelper.Assert.IsTrue(containDogeCoin, "Get child category with invalid language failed."); }
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."); }
public IEnumerator BatchGetGameProfile_Success() { GameProfiles gameProfiles = AccelBytePlugin.GetGameProfiles(); Result <UserGameProfiles[]> batchGetGameProfilesResults = null; string[] userIds = new string[] { this.user.Session.UserId, "some_random_user_id", "not_exist_user_id" }; gameProfiles.BatchGetGameProfiles(userIds, result => { batchGetGameProfilesResults = result; }); while (batchGetGameProfilesResults == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(batchGetGameProfilesResults, "Batch get game profiles"); Assert.That(!batchGetGameProfilesResults.IsError); bool gameProfileFound = false; bool notExistEmptyProfile = true; int notExistUserIdCount = 0; foreach (UserGameProfiles userGameProfile in batchGetGameProfilesResults.Value) { if (userGameProfile.userId == this.gameProfile.userId) { foreach (GameProfilePublicInfo profile in userGameProfile.gameProfiles) { if (profile.profileId == this.gameProfile.profileId) { gameProfileFound = true; } } } else if (userGameProfile.userId == "some_random_user_id") { notExistUserIdCount++; if (userGameProfile.gameProfiles.Length > 0) { notExistEmptyProfile = false; } } else if (userGameProfile.userId == "not_exist_user_id") { notExistUserIdCount++; if (userGameProfile.gameProfiles.Length > 0) { notExistEmptyProfile = false; } } } Assert.That(gameProfileFound); Assert.AreEqual(notExistUserIdCount, 2); Assert.That(notExistEmptyProfile); }
public EntitlementTokenGenerator(string[] itemIds, string[] appIds, string[] skus) { Assert.IsFalse(itemIds == null && appIds == null && skus == null, "Can't create entitlement token generator! all itemIds, appIds and skus parameters are null!"); this.entitlement = AccelBytePlugin.GetEntitlement(); this.itemIds = itemIds; this.appIds = appIds; this.skus = skus; }
/// <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); }
void SignIn() { try { Sony.NP.Auth.GetAuthCodeRequest request = new Sony.NP.Auth.GetAuthCodeRequest(); // test values from SDK nptoolkit sample ... replace with your own project values Sony.NP.Auth.NpClientId clientId = new Sony.NP.Auth.NpClientId(); clientId.Id = ""; request.ClientId = clientId; request.Scope = "psn:s2s"; request.UserId = GetLocalProfiles(); PrintLog("\nGet UserId Success! UserId: " + request.UserId); Sony.NP.Auth.AuthCodeResponse response = new Sony.NP.Auth.AuthCodeResponse(); int requestId = Sony.NP.Auth.GetAuthCode(request, response); while (response.Locked) { new WaitForSeconds(1); } PrintLog("\n Return Code: " + response.ReturnCode); PrintLog("\nIssuerId: " + response.IssuerId); if (!response.IsErrorCode) { PrintLog("\nAuthCode: " + response.AuthCode); var user = AccelBytePlugin.GetUser(); PrintLog("\nLogin to AB"); user.LoginWithOtherPlatform(AccelByte.Models.PlatformType.PS4, response.AuthCode, result => { if (!result.IsError) { PrintLog("\nLogin Success!"); user.GetData(resultData => { if (!resultData.IsError) { PrintLog("\nUserId: " + resultData.Value.userId); PrintLog("\nDisplayName: " + resultData.Value.displayName); } }); } }); } } catch (Sony.NP.NpToolkitException e) { PrintLog("\nException : " + e.ExtendedMessage); } }
public IEnumerator GetServerLatencies_QosServersAvailables_ReturnServerLatencies() { var qos = AccelBytePlugin.GetQos(); Result <Dictionary <string, int> > latenciesResult = null; qos.GetServerLatencies(result => latenciesResult = result); while (latenciesResult == null) { yield return(new WaitForSeconds(0.1f)); } TestHelper.Assert.That(latenciesResult.IsError, Is.False); TestHelper.Assert.That(latenciesResult.Value.Count, Is.GreaterThan(0)); }
public IEnumerator GetUserOrders_UserHasOrderHistory_Success() { Orders orders = AccelBytePlugin.GetOrders(); Result <OrderPagingSlicedResult> getUserOrdersResult = null; orders.GetUserOrders(0, 3, result => { getUserOrdersResult = result; }); while (getUserOrdersResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.Assert.IsTrue(!getUserOrdersResult.IsError, "Get user orders failed."); }
public IEnumerator GetWalletByCurrencyCode_CurrencyEmpty_Success() { Wallet wallet = AccelBytePlugin.GetWallet(); Result <WalletInfo> getWalletInfoResult = null; wallet.GetWalletInfoByCurrencyCode("", result => { getWalletInfoResult = result; }); while (getWalletInfoResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.Assert.IsTrue(getWalletInfoResult.IsError, "Get wallet with empty currency failed."); }
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."); }
public IEnumerator DeleteSlot_Success() { CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage(); Result deleteSlotResult = null; cloudStorage.DeleteSlot(this.createdSlot.slotId, result => { deleteSlotResult = result; }); while (deleteSlotResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(deleteSlotResult, "Delete a slot"); TestHelper.Assert.That(!deleteSlotResult.IsError); }