diff --git a/PlayFabClientSDK/source/PlayFabClientAPI.cs b/PlayFabClientSDK/source/PlayFabClientAPI.cs index 6daf9992..113e3399 100644 --- a/PlayFabClientSDK/source/PlayFabClientAPI.cs +++ b/PlayFabClientSDK/source/PlayFabClientAPI.cs @@ -584,7 +584,7 @@ public static async Task> GetPlay } /// - /// Retrieves all requested data for a user in one unified request. By default, this API returns all data for the locally signed-in user. The input parameters may be used to limit the data retrieved any any subset of the available data, as well as retrieve the available data for a different user. Note that certain data, including inventory, virtual currency balances, and personally identifying information, may only be retrieved for the locally signed-in user. In the example below, a request is made for the account details, virtual currency balances, and specified user data for the locally signed-in user. + /// Retrieves all requested data for a user in one unified request. By default, this API returns all data for the locally signed-in user. The input parameters may be used to limit the data retrieved to any subset of the available data, as well as retrieve the available data for a different user. Note that certain data, including inventory, virtual currency balances, and personally identifying information, may only be retrieved for the locally signed-in user. In the example below, a request is made for the account details, virtual currency balances, and specified user data for the locally signed-in user. /// public static async Task> GetUserCombinedInfoAsync(GetUserCombinedInfoRequest request) { diff --git a/PlayFabClientSDK/source/PlayFabVersion.cs b/PlayFabClientSDK/source/PlayFabVersion.cs index b485726a..a7552acd 100644 --- a/PlayFabClientSDK/source/PlayFabVersion.cs +++ b/PlayFabClientSDK/source/PlayFabVersion.cs @@ -3,7 +3,7 @@ namespace PlayFab.Internal { public class PlayFabVersion { - public static string ApiRevision = "1.5.20150901"; + public static string ApiRevision = "1.6.20150928"; public static string SdkRevision = "1.0.2"; public static string getVersionString() diff --git a/PlayFabClientSDK/source/Uunit/UUnitAssert.cs b/PlayFabClientSDK/source/Uunit/UUnitAssert.cs index 8b887f72..f7de7718 100644 --- a/PlayFabClientSDK/source/Uunit/UUnitAssert.cs +++ b/PlayFabClientSDK/source/Uunit/UUnitAssert.cs @@ -1,152 +1,109 @@ -/* - * UUnit system from UnityCommunity - * Heavily modified - * 0.4 release by pboechat - * http://wiki.unity3d.com/index.php?title=UUnit - * http://creativecommons.org/licenses/by-sa/3.0/ -*/ - -using System; - -namespace PlayFab.UUnit -{ - public class UUnitAssert - { - public static double DEFAULT_DOUBLE_PRECISION = 0.000001; - - private UUnitAssert() - { - } - - public static void Skip() - { - throw new UUnitSkipException(); - } - - public static void Fail(string message = null) - { - if (string.IsNullOrEmpty(message)) - message = "fail"; - throw new UUnitAssertException(message); - } - - public static void True(bool boolean, string message = null) - { - if (boolean) - { - return; - } - if (string.IsNullOrEmpty(message)) - throw new UUnitAssertException(true, false); - else - throw new UUnitAssertException(true, false, message); - } - - public static void False(bool boolean, string message = null) - { - if (!boolean) - { - return; - } - if (string.IsNullOrEmpty(message)) - throw new UUnitAssertException(true, false); - else - throw new UUnitAssertException(true, false, message); - } - - public static void NotNull(object something, string message = null) - { - if (something != null) - return; // Success - - if (string.IsNullOrEmpty(message)) - message = "Null object"; - throw new UUnitAssertException(message); - } - - public static void Null(object something, string message = null) - { - if (something == null) - return; - - if (string.IsNullOrEmpty(message)) - message = "Not null object"; - throw new UUnitAssertException(message); - } - - public static void Equals(string wanted, string got, string message) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got, message); - } - - public static void Equals(string wanted, string got) - { - if (wanted == got) - return; - throw new UUnitAssertException(wanted, got); - } - - public static void Equals(int wanted, int got, string message) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got, message); - } - - public static void Equals(int wanted, int got) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got); - } - - public static void Equals(double wanted, double got, double precision) - { - if (Math.Abs(wanted - got) < precision) - { - return; - } - throw new UUnitAssertException(wanted, got); - } - - public static void Equals(double wanted, double got) - { - Equals(wanted, got, DEFAULT_DOUBLE_PRECISION); - } - - public static void Equals(char wanted, char got) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got); - } - - public static void Equals(object wanted, object got, string message) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got, message); - } - - public new static void Equals(object wanted, object got) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got); - } - } -} \ No newline at end of file +/* + * UUnit system from UnityCommunity + * Heavily modified + * 0.4 release by pboechat + * http://wiki.unity3d.com/index.php?title=UUnit + * http://creativecommons.org/licenses/by-sa/3.0/ +*/ + +using System; + +namespace PlayFab.UUnit +{ + public static class UUnitAssert + { + public const double DEFAULT_DOUBLE_PRECISION = 0.000001; + + public static void Skip() + { + throw new UUnitSkipException(); + } + + public static void Fail(string message = null) + { + if (string.IsNullOrEmpty(message)) + message = "fail"; + throw new UUnitAssertException(message); + } + + public static void True(bool boolean, string message = null) + { + if (boolean) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: true, Actual: false"; + throw new UUnitAssertException(true, false, message); + } + + public static void False(bool boolean, string message = null) + { + if (!boolean) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: false, Actual: true"; + throw new UUnitAssertException(true, false, message); + } + + public static void NotNull(object something, string message = null) + { + if (something != null) + return; // Success + + if (string.IsNullOrEmpty(message)) + message = "Null object"; + throw new UUnitAssertException(message); + } + + public static void Null(object something, string message = null) + { + if (something == null) + return; + + if (string.IsNullOrEmpty(message)) + message = "Not null object"; + throw new UUnitAssertException(message); + } + + public static void Equals(string wanted, string got, string message = null) + { + if (wanted == got) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: " + wanted + ", Actual: " + got; + throw new UUnitAssertException(wanted, got, message); + } + + public static void Equals(int wanted, int got, string message = null) + { + if (wanted == got) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: " + wanted + ", Actual: " + got; + throw new UUnitAssertException(wanted, got, message); + } + + public static void Equals(double wanted, double got, double precision = DEFAULT_DOUBLE_PRECISION, string message = null) + { + if (Math.Abs(wanted - got) < precision) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: " + wanted + ", Actual: " + got; + throw new UUnitAssertException(wanted, got, message); + } + + public static void Equals(object wanted, object got, string message = null) + { + if (wanted == got) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: " + wanted + ", Actual: " + got; + throw new UUnitAssertException(wanted, got, message); + } + } +} diff --git a/PlayFabClientSDK/source/Uunit/UUnitAssertException.cs b/PlayFabClientSDK/source/Uunit/UUnitAssertException.cs index 4c22040d..94ce32f8 100644 --- a/PlayFabClientSDK/source/Uunit/UUnitAssertException.cs +++ b/PlayFabClientSDK/source/Uunit/UUnitAssertException.cs @@ -1,50 +1,43 @@ -/* - * UUnit system from UnityCommunity - * Heavily modified - * 0.4 release by pboechat - * http://wiki.unity3d.com/index.php?title=UUnit - * http://creativecommons.org/licenses/by-sa/3.0/ -*/ - -using System; - -namespace PlayFab.UUnit -{ - /// - /// Throw this exception, via UUnitAssert utility function, in order to define when a test has been skipped. - /// The only information shown will be the "skipped" notification - /// - public class UUnitSkipException : Exception { } - - /// - /// Throw this exception, via UUnitAssert utility functions, in order to define when a test has failed. - /// The traceback and message will automatically be displayed as a failure - /// - public class UUnitAssertException : Exception - { - public object expected; - public object received; - public string message; - - public UUnitAssertException(string message) - : base(message) - { - this.message = message; - } - - public UUnitAssertException(object expected, object received, string message) - : base("[UUnit] - Assert Failed - Expected: " + expected + " Received: " + received + "\n\t\t(" + message + ")") - { - this.expected = (expected == null) ? "null" : expected; - this.received = (received == null) ? "null" : received; - this.message = (message == null) ? "" : message; - } - - public UUnitAssertException(object expected, object received) - : base("[UUnit] - Assert Failed - Expected: " + expected + " Received: " + received) - { - this.expected = (expected == null) ? "null" : expected; - this.received = (received == null) ? "null" : received; - } - } -} \ No newline at end of file +/* + * UUnit system from UnityCommunity + * Heavily modified + * 0.4 release by pboechat + * http://wiki.unity3d.com/index.php?title=UUnit + * http://creativecommons.org/licenses/by-sa/3.0/ +*/ + +using System; + +namespace PlayFab.UUnit +{ + /// + /// Throw this exception, via UUnitAssert utility function, in order to define when a test has been skipped. + /// The only information shown will be the "skipped" notification + /// + public class UUnitSkipException : Exception { } + + /// + /// Throw this exception, via UUnitAssert utility functions, in order to define when a test has failed. + /// The traceback and message will automatically be displayed as a failure + /// + public class UUnitAssertException : Exception + { + public object expected; + public object received; + public string message; + + public UUnitAssertException(string message) + : base(message) + { + this.message = message; + } + + public UUnitAssertException(object expected, object received, string message) + : base("[UUnit] - Assert Failed - Expected: " + expected + " Received: " + received + "\n\t\t(" + message + ")") + { + this.expected = (expected == null) ? "null" : expected; + this.received = (received == null) ? "null" : received; + this.message = (message == null) ? "" : message; + } + } +} diff --git a/PlayFabSDK/UnittestRunner/PlayFabApiTest.cs b/PlayFabSDK/UnittestRunner/PlayFabApiTest.cs index 8a9e13c8..9e1ba9e1 100644 --- a/PlayFabSDK/UnittestRunner/PlayFabApiTest.cs +++ b/PlayFabSDK/UnittestRunner/PlayFabApiTest.cs @@ -1,322 +1,383 @@ -using PlayFab; -using System; -using System.Collections.Generic; - -namespace PlayFab.UUnit -{ - /// - /// A real system would potentially run only the client or server API, and not both. - /// But, they still interact with eachother directly. - /// The tests can't be independent for Client/Server, as the sequence of calls isn't really independent for real-world scenarios. - /// The client logs in, which triggers a server, and then back and forth. - /// For the purpose of testing, they each have pieces of information they share with one another, and that sharing makes various calls possible. - /// - public class PlayFabApiTest : UUnitTestCase - { - private const int TEST_STAT_BASE = 10; - private const string TEST_STAT_NAME = "str"; - private const string CHAR_TEST_TYPE = "Test"; - - // Functional - private static bool TITLE_INFO_SET = false; - private static bool TITLE_CAN_UPDATE_SETTINGS = false; - - // Fixed values provided from testInputs - private static string USER_NAME; - private static string USER_EMAIL; - private static string USER_PASSWORD; - private static string CHAR_NAME; - - // Information fetched by appropriate API calls - private static string playFabId; - private static string characterId; - - /// - /// PlayFab Title cannot be created from SDK tests, so you must provide your titleId to run unit tests. - /// (Also, we don't want lots of excess unused titles) - /// - public static void SetTitleInfo(Dictionary testInputs) - { - string eachValue; - - TITLE_INFO_SET = true; - - // Parse all the inputs - TITLE_INFO_SET &= testInputs.TryGetValue("titleId", out eachValue); - PlayFabSettings.TitleId = eachValue; - TITLE_INFO_SET &= testInputs.TryGetValue("developerSecretKey", out eachValue); - PlayFabSettings.DeveloperSecretKey = eachValue; - - TITLE_INFO_SET &= testInputs.TryGetValue("titleCanUpdateSettings", out eachValue); - TITLE_INFO_SET &= bool.TryParse(eachValue, out TITLE_CAN_UPDATE_SETTINGS); - - TITLE_INFO_SET &= testInputs.TryGetValue("userName", out USER_NAME); - TITLE_INFO_SET &= testInputs.TryGetValue("userEmail", out USER_EMAIL); - TITLE_INFO_SET &= testInputs.TryGetValue("userPassword", out USER_PASSWORD); - - TITLE_INFO_SET &= testInputs.TryGetValue("characterName", out CHAR_NAME); - - // Verify all the inputs won't cause crashes in the tests - TITLE_INFO_SET &= !string.IsNullOrEmpty(PlayFabSettings.TitleId) - && !string.IsNullOrEmpty(PlayFabSettings.DeveloperSecretKey) - && !string.IsNullOrEmpty(USER_NAME) - && !string.IsNullOrEmpty(USER_EMAIL) - && !string.IsNullOrEmpty(USER_PASSWORD) - && !string.IsNullOrEmpty(CHAR_NAME); - } - - protected override void SetUp() - { - if (!TITLE_INFO_SET) - UUnitAssert.Skip(); // We cannot do client tests if the titleId is not given - } - - protected override void TearDown() - { - // TODO: Destroy any characters - } - - /// - /// CLIENT API - /// Try to deliberately log in with an inappropriate password, - /// and verify that the error displays as expected. - /// - [UUnitTest] - public void InvalidLogin() - { - // If the setup failed to log in a user, we need to create one. - var request = new ClientModels.LoginWithEmailAddressRequest(); - request.TitleId = PlayFabSettings.TitleId; - request.Email = USER_EMAIL; - request.Password = USER_PASSWORD + "INVALID"; - var task = PlayFabClientAPI.LoginWithEmailAddressAsync(request); - task.Wait(); - UUnitAssert.NotNull(task.Result); - UUnitAssert.Null(task.Result.Result); - UUnitAssert.NotNull(task.Result.Error); - UUnitAssert.True(task.Result.Error.ErrorMessage.Contains("password")); - } - - /// - /// CLIENT API - /// Log in or create a user, track their PlayFabId - /// - [UUnitTest] - public void LoginOrRegister() - { - if (!PlayFabClientAPI.IsClientLoggedIn()) // If we haven't already logged in... - { - var loginRequest = new ClientModels.LoginWithEmailAddressRequest(); - loginRequest.Email = USER_EMAIL; - loginRequest.Password = USER_PASSWORD; - loginRequest.TitleId = PlayFabSettings.TitleId; - var loginTask = PlayFabClientAPI.LoginWithEmailAddressAsync(loginRequest); - loginTask.Wait(); - - if (loginTask.Result != null && loginTask.Result.Result != null) // If successful, track playFabId - playFabId = loginTask.Result.Result.PlayFabId; // Needed for subsequent tests - } - - if (PlayFabClientAPI.IsClientLoggedIn()) - return; // Success, already logged in - - // If the setup failed to log in a user, we need to create one. - var registerRequest = new ClientModels.RegisterPlayFabUserRequest(); - registerRequest.TitleId = PlayFabSettings.TitleId; - registerRequest.Username = USER_NAME; - registerRequest.Email = USER_EMAIL; - registerRequest.Password = USER_PASSWORD; - var registerTask = PlayFabClientAPI.RegisterPlayFabUserAsync(registerRequest); - registerTask.Wait(); - UUnitAssert.NotNull(registerTask.Result); - UUnitAssert.Null(registerTask.Result.Error); - UUnitAssert.NotNull(registerTask.Result.Result); - - playFabId = registerTask.Result.Result.PlayFabId; // Needed for subsequent tests - - UUnitAssert.True(PlayFabClientAPI.IsClientLoggedIn(), "User login failed"); - } - - /// - /// CLIENT API - /// Test a sequence of calls that modifies saved data, - /// and verifies that the next sequential API call contains updated data. - /// Verify that the data is correctly modified on the next call. - /// Parameter types tested: string, Dictionary, DateTime - /// - [UUnitTest] - public void UserDataApi() - { - string TEST_KEY = "testCounter"; - - ClientModels.UserDataRecord testCounter; - int testCounterValueExpected, testCounterValueActual; - DateTime timeInitial, timeUpdated; - - var getRequest = new ClientModels.GetUserDataRequest(); - var getDataTask1 = PlayFabClientAPI.GetUserDataAsync(getRequest); - getDataTask1.Wait(); - UUnitAssert.Null(getDataTask1.Result.Error, "UserData should have been retrieved from Api call"); - UUnitAssert.NotNull(getDataTask1.Result.Result, "UserData should have been retrieved from Api call"); - UUnitAssert.NotNull(getDataTask1.Result.Result.Data, "UserData should have been retrieved from Api call"); - if (!getDataTask1.Result.Result.Data.TryGetValue(TEST_KEY, out testCounter)) - { - testCounter = new ClientModels.UserDataRecord(); - testCounter.Value = "0"; - } - int.TryParse(testCounter.Value, out testCounterValueExpected); - timeInitial = testCounter.LastUpdated; - testCounterValueExpected = (testCounterValueExpected + 1) % 100; // This test is about the expected value changing - but not testing more complicated issues like bounds - - var updateRequest = new ClientModels.UpdateUserDataRequest(); - updateRequest.Data = new Dictionary(); - updateRequest.Data[TEST_KEY] = testCounterValueExpected.ToString(); - var updateTask = PlayFabClientAPI.UpdateUserDataAsync(updateRequest); - updateTask.Wait(); // The update doesn't return anything interesting except versionID. It's better to just re-call GetUserData again below to verify the update - UUnitAssert.Null(updateTask.Result.Error, "UpdateUserData call failed"); - UUnitAssert.NotNull(updateTask.Result.Result, "UpdateUserData call failed"); - - getRequest = new ClientModels.GetUserDataRequest(); - var getDataTask2 = PlayFabClientAPI.GetUserDataAsync(getRequest); - getDataTask2.Wait(); - UUnitAssert.Null(getDataTask2.Result.Error, "UserData should have been retrieved from Api call"); - UUnitAssert.NotNull(getDataTask2.Result.Result, "UserData should have been retrieved from Api call"); - UUnitAssert.NotNull(getDataTask2.Result.Result.Data, "UserData should have been retrieved from Api call"); - getDataTask2.Result.Result.Data.TryGetValue(TEST_KEY, out testCounter); - UUnitAssert.NotNull(testCounter, "The updated UserData was not found in the Api results"); - int.TryParse(testCounter.Value, out testCounterValueActual); - timeUpdated = testCounter.LastUpdated; - UUnitAssert.Equals(testCounterValueExpected, testCounterValueActual); - UUnitAssert.True(timeUpdated > timeInitial); - } - - /// - /// CLIENT API - /// Test a sequence of calls that modifies saved data, - /// and verifies that the next sequential API call contains updated data. - /// Verify that the data is saved correctly, and that specific types are tested - /// Parameter types tested: Dictionary - /// - [UUnitTest] - public void UserStatisticsApi() - { - int testStatExpected, testStatActual; - - var getRequest = new ClientModels.GetUserStatisticsRequest(); - var getStatTask1 = PlayFabClientAPI.GetUserStatisticsAsync(getRequest); - getStatTask1.Wait(); - UUnitAssert.Null(getStatTask1.Result.Error, "UserStatistics should have been retrieved from Api call"); - UUnitAssert.NotNull(getStatTask1.Result.Result, "UserStatistics should have been retrieved from Api call"); - UUnitAssert.NotNull(getStatTask1.Result.Result.UserStatistics, "UserStatistics should have been retrieved from Api call"); - if (!getStatTask1.Result.Result.UserStatistics.TryGetValue(TEST_STAT_NAME, out testStatExpected)) - testStatExpected = TEST_STAT_BASE; - testStatExpected = ((testStatExpected + 1) % TEST_STAT_BASE) + TEST_STAT_BASE; // This test is about the expected value changing (incrementing through from TEST_STAT_BASE to TEST_STAT_BASE * 2 - 1) - - var updateRequest = new ClientModels.UpdateUserStatisticsRequest(); - updateRequest.UserStatistics = new Dictionary(); - updateRequest.UserStatistics[TEST_STAT_NAME] = testStatExpected; - var updateTask = PlayFabClientAPI.UpdateUserStatisticsAsync(updateRequest); - updateTask.Wait(); // The update doesn't return anything, so can't test anything other than failure - - // Test update result - no data returned, so error or no error, based on Title settings - if (!TITLE_CAN_UPDATE_SETTINGS) - { - UUnitAssert.Null(updateTask.Result.Result, "UpdateStatistics should have failed"); - UUnitAssert.NotNull(updateTask.Result.Error, "UpdateStatistics should have failed"); - return; // The rest of this tests changing settings - Which we verified we cannot do - } - else // if (CAN_UPDATE_SETTINGS) - { - UUnitAssert.Null(updateTask.Result.Error, "UpdateStatistics call failed"); - UUnitAssert.NotNull(updateTask.Result.Result, "UpdateStatistics call failed"); - } - - getRequest = new ClientModels.GetUserStatisticsRequest(); - var getStatTask2 = PlayFabClientAPI.GetUserStatisticsAsync(getRequest); - getStatTask2.Wait(); - UUnitAssert.Null(getStatTask2.Result.Error, "UserStatistics should have been retrieved from Api call"); - UUnitAssert.NotNull(getStatTask2.Result.Result, "UserStatistics should have been retrieved from Api call"); - UUnitAssert.NotNull(getStatTask2.Result.Result.UserStatistics, "UserStatistics should have been retrieved from Api call"); - getStatTask2.Result.Result.UserStatistics.TryGetValue(TEST_STAT_NAME, out testStatActual); - UUnitAssert.Equals(testStatExpected, testStatActual); - } - - /// - /// SERVER API - /// Get or create the given test character for the given user - /// Parameter types tested: Contained-Classes, string - /// - [UUnitTest] - public void UserCharacter() - { - var request = new ServerModels.ListUsersCharactersRequest(); - request.PlayFabId = playFabId; // Received from client upon login - var getCharsTask = PlayFabServerAPI.GetAllUsersCharactersAsync(request); - getCharsTask.Wait(); - UUnitAssert.Null(getCharsTask.Result.Error, "Failed to GetChars"); - UUnitAssert.NotNull(getCharsTask.Result.Result, "Failed to GetChars"); - UUnitAssert.NotNull(getCharsTask.Result.Result.Characters, "Failed to GetChars"); - - ServerModels.CharacterResult targetCharacter = null; - foreach (var eachCharacter in getCharsTask.Result.Result.Characters) - if (eachCharacter.CharacterName == CHAR_NAME) - targetCharacter = eachCharacter; - - if (targetCharacter == null) - { - // Create the targetCharacter since it doesn't exist - var grantRequest = new ServerModels.GrantCharacterToUserRequest(); - grantRequest.PlayFabId = playFabId; - grantRequest.CharacterName = CHAR_NAME; - grantRequest.CharacterType = CHAR_TEST_TYPE; - var grantTask = PlayFabServerAPI.GrantCharacterToUserAsync(grantRequest); - grantTask.Wait(); - UUnitAssert.Null(grantTask.Result.Error, "Grant character failed"); - UUnitAssert.NotNull(grantTask.Result.Result, "Grant character failed"); - UUnitAssert.NotNull(grantTask.Result.Result.CharacterId, "Grant character failed"); - - // Attempt to get characters again - getCharsTask = PlayFabServerAPI.GetAllUsersCharactersAsync(request); - getCharsTask.Wait(); - UUnitAssert.Null(getCharsTask.Result.Error, "Failed to GetChars"); - UUnitAssert.NotNull(getCharsTask.Result.Result, "Failed to GetChars"); - UUnitAssert.NotNull(getCharsTask.Result.Result.Characters, "Failed to GetChars"); - foreach (var eachCharacter in getCharsTask.Result.Result.Characters) - if (eachCharacter.CharacterName == CHAR_NAME) - targetCharacter = eachCharacter; - } - - // Save the requested character - UUnitAssert.NotNull(targetCharacter, "The test character did not exist, and was not successfully created"); - characterId = targetCharacter.CharacterId; - } - - /// - /// CLIENT AND SERVER API - /// Test that leaderboard results can be requested - /// Parameter types tested: List of contained-classes - /// - [UUnitTest] - public void LeaderBoard() - { - var clientRequest = new ClientModels.GetLeaderboardAroundCurrentUserRequest(); - clientRequest.MaxResultsCount = 3; - clientRequest.StatisticName = TEST_STAT_NAME; - var clientTask = PlayFabClientAPI.GetLeaderboardAroundCurrentUserAsync(clientRequest); - UUnitAssert.Null(clientTask.Result.Error, "Failed to get client leaderboard"); - UUnitAssert.NotNull(clientTask.Result.Result, "Failed to get client leaderboard"); - UUnitAssert.NotNull(clientTask.Result.Result.Leaderboard, "Failed to get client leaderboard"); - // Testing anything more would be testing actual functionality of the Leaderboard, which is outside the scope of this test. - - var serverRequest = new ServerModels.GetLeaderboardAroundCharacterRequest(); - serverRequest.MaxResultsCount = 3; - serverRequest.StatisticName = TEST_STAT_NAME; - serverRequest.CharacterId = characterId; - serverRequest.PlayFabId = playFabId; - var serverTask = PlayFabServerAPI.GetLeaderboardAroundCharacterAsync(serverRequest); - UUnitAssert.Null(serverTask.Result.Error, "Failed to get server leaderboard"); - UUnitAssert.NotNull(serverTask.Result.Result, "Failed to get server leaderboard"); - UUnitAssert.NotNull(serverTask.Result.Result.Leaderboard, "Failed to get server leaderboard"); - } - } -} +using PlayFab; +using System; +using System.Collections.Generic; +using Newtonsoft.Json.Linq; + +namespace PlayFab.UUnit +{ + /// + /// A real system would potentially run only the client or server API, and not both. + /// But, they still interact with eachother directly. + /// The tests can't be independent for Client/Server, as the sequence of calls isn't really independent for real-world scenarios. + /// The client logs in, which triggers a server, and then back and forth. + /// For the purpose of testing, they each have pieces of information they share with one another, and that sharing makes various calls possible. + /// + public class PlayFabApiTest : UUnitTestCase + { + private const int TEST_STAT_BASE = 10; + private const string TEST_STAT_NAME = "str"; + private const string CHAR_TEST_TYPE = "Test"; + + // Functional + private static bool TITLE_INFO_SET = false; + private static bool TITLE_CAN_UPDATE_SETTINGS = false; + + // Fixed values provided from testInputs + private static string USER_NAME; + private static string USER_EMAIL; + private static string USER_PASSWORD; + private static string CHAR_NAME; + + // Information fetched by appropriate API calls + private static string playFabId; + private static string characterId; + + /// + /// PlayFab Title cannot be created from SDK tests, so you must provide your titleId to run unit tests. + /// (Also, we don't want lots of excess unused titles) + /// + public static void SetTitleInfo(Dictionary testInputs) + { + string eachValue; + + TITLE_INFO_SET = true; + + // Parse all the inputs + TITLE_INFO_SET &= testInputs.TryGetValue("titleId", out eachValue); + PlayFabSettings.TitleId = eachValue; + TITLE_INFO_SET &= testInputs.TryGetValue("developerSecretKey", out eachValue); + PlayFabSettings.DeveloperSecretKey = eachValue; + + TITLE_INFO_SET &= testInputs.TryGetValue("titleCanUpdateSettings", out eachValue); + TITLE_INFO_SET &= bool.TryParse(eachValue, out TITLE_CAN_UPDATE_SETTINGS); + + TITLE_INFO_SET &= testInputs.TryGetValue("userName", out USER_NAME); + TITLE_INFO_SET &= testInputs.TryGetValue("userEmail", out USER_EMAIL); + TITLE_INFO_SET &= testInputs.TryGetValue("userPassword", out USER_PASSWORD); + + TITLE_INFO_SET &= testInputs.TryGetValue("characterName", out CHAR_NAME); + + // Verify all the inputs won't cause crashes in the tests + TITLE_INFO_SET &= !string.IsNullOrEmpty(PlayFabSettings.TitleId) + && !string.IsNullOrEmpty(PlayFabSettings.DeveloperSecretKey) + && !string.IsNullOrEmpty(USER_NAME) + && !string.IsNullOrEmpty(USER_EMAIL) + && !string.IsNullOrEmpty(USER_PASSWORD) + && !string.IsNullOrEmpty(CHAR_NAME); + } + + protected override void SetUp() + { + if (!TITLE_INFO_SET) + UUnitAssert.Skip(); // We cannot do client tests if the titleId is not given + } + + protected override void TearDown() + { + // TODO: Destroy any characters + } + + /// + /// CLIENT API + /// Try to deliberately log in with an inappropriate password, + /// and verify that the error displays as expected. + /// + [UUnitTest] + public void InvalidLogin() + { + // If the setup failed to log in a user, we need to create one. + var request = new ClientModels.LoginWithEmailAddressRequest(); + request.TitleId = PlayFabSettings.TitleId; + request.Email = USER_EMAIL; + request.Password = USER_PASSWORD + "INVALID"; + var task = PlayFabClientAPI.LoginWithEmailAddressAsync(request); + task.Wait(); + UUnitAssert.NotNull(task.Result); + UUnitAssert.Null(task.Result.Result); + UUnitAssert.NotNull(task.Result.Error); + UUnitAssert.True(task.Result.Error.ErrorMessage.Contains("password")); + } + + /// + /// CLIENT API + /// Log in or create a user, track their PlayFabId + /// + [UUnitTest] + public void LoginOrRegister() + { + if (!PlayFabClientAPI.IsClientLoggedIn()) // If we haven't already logged in... + { + var loginRequest = new ClientModels.LoginWithEmailAddressRequest(); + loginRequest.Email = USER_EMAIL; + loginRequest.Password = USER_PASSWORD; + loginRequest.TitleId = PlayFabSettings.TitleId; + var loginTask = PlayFabClientAPI.LoginWithEmailAddressAsync(loginRequest); + loginTask.Wait(); + + if (loginTask.Result != null && loginTask.Result.Result != null) // If successful, track playFabId + playFabId = loginTask.Result.Result.PlayFabId; // Needed for subsequent tests + } + + if (PlayFabClientAPI.IsClientLoggedIn()) + return; // Success, already logged in + + // If the setup failed to log in a user, we need to create one. + var registerRequest = new ClientModels.RegisterPlayFabUserRequest(); + registerRequest.TitleId = PlayFabSettings.TitleId; + registerRequest.Username = USER_NAME; + registerRequest.Email = USER_EMAIL; + registerRequest.Password = USER_PASSWORD; + var registerTask = PlayFabClientAPI.RegisterPlayFabUserAsync(registerRequest); + registerTask.Wait(); + UUnitAssert.NotNull(registerTask.Result); + UUnitAssert.Null(registerTask.Result.Error); + UUnitAssert.NotNull(registerTask.Result.Result); + + playFabId = registerTask.Result.Result.PlayFabId; // Needed for subsequent tests + + UUnitAssert.True(PlayFabClientAPI.IsClientLoggedIn(), "User login failed"); + } + + /// + /// CLIENT API + /// Test a sequence of calls that modifies saved data, + /// and verifies that the next sequential API call contains updated data. + /// Verify that the data is correctly modified on the next call. + /// Parameter types tested: string, Dictionary, DateTime + /// + [UUnitTest] + public void UserDataApi() + { + string TEST_KEY = "testCounter"; + + ClientModels.UserDataRecord testCounter; + int testCounterValueExpected, testCounterValueActual; + DateTime timeInitial, timeUpdated; + + var getRequest = new ClientModels.GetUserDataRequest(); + var getDataTask1 = PlayFabClientAPI.GetUserDataAsync(getRequest); + getDataTask1.Wait(); + UUnitAssert.Null(getDataTask1.Result.Error, "UserData should have been retrieved from Api call"); + UUnitAssert.NotNull(getDataTask1.Result.Result, "UserData should have been retrieved from Api call"); + UUnitAssert.NotNull(getDataTask1.Result.Result.Data, "UserData should have been retrieved from Api call"); + if (!getDataTask1.Result.Result.Data.TryGetValue(TEST_KEY, out testCounter)) + { + testCounter = new ClientModels.UserDataRecord(); + testCounter.Value = "0"; + } + int.TryParse(testCounter.Value, out testCounterValueExpected); + timeInitial = testCounter.LastUpdated; + testCounterValueExpected = (testCounterValueExpected + 1) % 100; // This test is about the expected value changing - but not testing more complicated issues like bounds + + var updateRequest = new ClientModels.UpdateUserDataRequest(); + updateRequest.Data = new Dictionary(); + updateRequest.Data[TEST_KEY] = testCounterValueExpected.ToString(); + var updateTask = PlayFabClientAPI.UpdateUserDataAsync(updateRequest); + updateTask.Wait(); // The update doesn't return anything interesting except versionID. It's better to just re-call GetUserData again below to verify the update + UUnitAssert.Null(updateTask.Result.Error, "UpdateUserData call failed"); + UUnitAssert.NotNull(updateTask.Result.Result, "UpdateUserData call failed"); + + getRequest = new ClientModels.GetUserDataRequest(); + var getDataTask2 = PlayFabClientAPI.GetUserDataAsync(getRequest); + getDataTask2.Wait(); + UUnitAssert.Null(getDataTask2.Result.Error, "UserData should have been retrieved from Api call"); + UUnitAssert.NotNull(getDataTask2.Result.Result, "UserData should have been retrieved from Api call"); + UUnitAssert.NotNull(getDataTask2.Result.Result.Data, "UserData should have been retrieved from Api call"); + getDataTask2.Result.Result.Data.TryGetValue(TEST_KEY, out testCounter); + UUnitAssert.NotNull(testCounter, "The updated UserData was not found in the Api results"); + int.TryParse(testCounter.Value, out testCounterValueActual); + timeUpdated = testCounter.LastUpdated; + UUnitAssert.Equals(testCounterValueExpected, testCounterValueActual); + UUnitAssert.True(timeUpdated > timeInitial); + } + + /// + /// CLIENT API + /// Test a sequence of calls that modifies saved data, + /// and verifies that the next sequential API call contains updated data. + /// Verify that the data is saved correctly, and that specific types are tested + /// Parameter types tested: Dictionary + /// + [UUnitTest] + public void UserStatisticsApi() + { + int testStatExpected, testStatActual; + + var getRequest = new ClientModels.GetUserStatisticsRequest(); + var getStatTask1 = PlayFabClientAPI.GetUserStatisticsAsync(getRequest); + getStatTask1.Wait(); + UUnitAssert.Null(getStatTask1.Result.Error, "UserStatistics should have been retrieved from Api call"); + UUnitAssert.NotNull(getStatTask1.Result.Result, "UserStatistics should have been retrieved from Api call"); + UUnitAssert.NotNull(getStatTask1.Result.Result.UserStatistics, "UserStatistics should have been retrieved from Api call"); + if (!getStatTask1.Result.Result.UserStatistics.TryGetValue(TEST_STAT_NAME, out testStatExpected)) + testStatExpected = TEST_STAT_BASE; + testStatExpected = ((testStatExpected + 1) % TEST_STAT_BASE) + TEST_STAT_BASE; // This test is about the expected value changing (incrementing through from TEST_STAT_BASE to TEST_STAT_BASE * 2 - 1) + + var updateRequest = new ClientModels.UpdateUserStatisticsRequest(); + updateRequest.UserStatistics = new Dictionary(); + updateRequest.UserStatistics[TEST_STAT_NAME] = testStatExpected; + var updateTask = PlayFabClientAPI.UpdateUserStatisticsAsync(updateRequest); + updateTask.Wait(); // The update doesn't return anything, so can't test anything other than failure + + // Test update result - no data returned, so error or no error, based on Title settings + if (!TITLE_CAN_UPDATE_SETTINGS) + { + UUnitAssert.Null(updateTask.Result.Result, "UpdateStatistics should have failed"); + UUnitAssert.NotNull(updateTask.Result.Error, "UpdateStatistics should have failed"); + return; // The rest of this tests changing settings - Which we verified we cannot do + } + else // if (CAN_UPDATE_SETTINGS) + { + UUnitAssert.Null(updateTask.Result.Error, "UpdateStatistics call failed"); + UUnitAssert.NotNull(updateTask.Result.Result, "UpdateStatistics call failed"); + } + + getRequest = new ClientModels.GetUserStatisticsRequest(); + var getStatTask2 = PlayFabClientAPI.GetUserStatisticsAsync(getRequest); + getStatTask2.Wait(); + UUnitAssert.Null(getStatTask2.Result.Error, "UserStatistics should have been retrieved from Api call"); + UUnitAssert.NotNull(getStatTask2.Result.Result, "UserStatistics should have been retrieved from Api call"); + UUnitAssert.NotNull(getStatTask2.Result.Result.UserStatistics, "UserStatistics should have been retrieved from Api call"); + getStatTask2.Result.Result.UserStatistics.TryGetValue(TEST_STAT_NAME, out testStatActual); + UUnitAssert.Equals(testStatExpected, testStatActual); + } + + /// + /// SERVER API + /// Get or create the given test character for the given user + /// Parameter types tested: Contained-Classes, string + /// + [UUnitTest] + public void UserCharacter() + { + var request = new ServerModels.ListUsersCharactersRequest(); + request.PlayFabId = playFabId; // Received from client upon login + var getCharsTask = PlayFabServerAPI.GetAllUsersCharactersAsync(request); + getCharsTask.Wait(); + UUnitAssert.Null(getCharsTask.Result.Error, "Failed to GetChars"); + UUnitAssert.NotNull(getCharsTask.Result.Result, "Failed to GetChars"); + UUnitAssert.NotNull(getCharsTask.Result.Result.Characters, "Failed to GetChars"); + + ServerModels.CharacterResult targetCharacter = null; + foreach (var eachCharacter in getCharsTask.Result.Result.Characters) + if (eachCharacter.CharacterName == CHAR_NAME) + targetCharacter = eachCharacter; + + if (targetCharacter == null) + { + // Create the targetCharacter since it doesn't exist + var grantRequest = new ServerModels.GrantCharacterToUserRequest(); + grantRequest.PlayFabId = playFabId; + grantRequest.CharacterName = CHAR_NAME; + grantRequest.CharacterType = CHAR_TEST_TYPE; + var grantTask = PlayFabServerAPI.GrantCharacterToUserAsync(grantRequest); + grantTask.Wait(); + UUnitAssert.Null(grantTask.Result.Error, "Grant character failed"); + UUnitAssert.NotNull(grantTask.Result.Result, "Grant character failed"); + UUnitAssert.NotNull(grantTask.Result.Result.CharacterId, "Grant character failed"); + + // Attempt to get characters again + getCharsTask = PlayFabServerAPI.GetAllUsersCharactersAsync(request); + getCharsTask.Wait(); + UUnitAssert.Null(getCharsTask.Result.Error, "Failed to GetChars"); + UUnitAssert.NotNull(getCharsTask.Result.Result, "Failed to GetChars"); + UUnitAssert.NotNull(getCharsTask.Result.Result.Characters, "Failed to GetChars"); + foreach (var eachCharacter in getCharsTask.Result.Result.Characters) + if (eachCharacter.CharacterName == CHAR_NAME) + targetCharacter = eachCharacter; + } + + // Save the requested character + UUnitAssert.NotNull(targetCharacter, "The test character did not exist, and was not successfully created"); + characterId = targetCharacter.CharacterId; + } + + /// + /// CLIENT AND SERVER API + /// Test that leaderboard results can be requested + /// Parameter types tested: List of contained-classes + /// + [UUnitTest] + public void LeaderBoard() + { + var clientRequest = new ClientModels.GetLeaderboardAroundCurrentUserRequest(); + clientRequest.MaxResultsCount = 3; + clientRequest.StatisticName = TEST_STAT_NAME; + var clientTask = PlayFabClientAPI.GetLeaderboardAroundCurrentUserAsync(clientRequest); + clientTask.Wait(); + UUnitAssert.Null(clientTask.Result.Error, "Failed to get client leaderboard"); + UUnitAssert.NotNull(clientTask.Result.Result, "Failed to get client leaderboard"); + UUnitAssert.NotNull(clientTask.Result.Result.Leaderboard, "Failed to get client leaderboard"); + UUnitAssert.True(clientTask.Result.Result.Leaderboard.Count > 0, "Leaderboard does not contain enough entries."); + + var serverRequest = new ServerModels.GetLeaderboardAroundCharacterRequest(); + serverRequest.MaxResultsCount = 3; + serverRequest.StatisticName = TEST_STAT_NAME; + serverRequest.CharacterId = characterId; + serverRequest.PlayFabId = playFabId; + var serverTask = PlayFabServerAPI.GetLeaderboardAroundCharacterAsync(serverRequest); + clientTask.Wait(); + UUnitAssert.Null(serverTask.Result.Error, "Failed to get server leaderboard"); + UUnitAssert.NotNull(serverTask.Result.Result, "Failed to get server leaderboard"); + UUnitAssert.NotNull(serverTask.Result.Result.Leaderboard, "Failed to get server leaderboard"); + UUnitAssert.True(serverTask.Result.Result.Leaderboard.Count > 0, "Leaderboard does not contain enough entries."); + } + + /// + /// CLIENT API + /// Test that AccountInfo can be requested + /// Parameter types tested: List of enum-as-strings converted to list of enums + /// + [UUnitTest] + public void AccountInfo() + { + ClientModels.GetAccountInfoRequest request = new ClientModels.GetAccountInfoRequest(); + request.PlayFabId = playFabId; + var task = PlayFabClientAPI.GetAccountInfoAsync(request); + task.Wait(); + UUnitAssert.Null(task.Result.Error, "Failed to get accountInfo"); + UUnitAssert.NotNull(task.Result.Result, "Failed to get accountInfo"); + UUnitAssert.NotNull(task.Result.Result.AccountInfo, "Failed to get accountInfo"); + UUnitAssert.NotNull(task.Result.Result.AccountInfo.TitleInfo, "Failed to get accountInfo"); + UUnitAssert.NotNull(task.Result.Result.AccountInfo.TitleInfo.Origination, "Failed to get Origination Enum"); + UUnitAssert.True(Enum.IsDefined(typeof(ClientModels.UserOrigination), task.Result.Result.AccountInfo.TitleInfo.Origination.Value), "Origination Enum not valid"); + } + + /// + /// CLIENT API + /// Test that CloudScript can be properly set up and invoked + /// + [UUnitTest] + public void CloudScript() + { + if (string.IsNullOrEmpty(PlayFabSettings.LogicServerURL)) + { + var getUrlTask = PlayFabClientAPI.GetCloudScriptUrlAsync(new ClientModels.GetCloudScriptUrlRequest()); + getUrlTask.Wait(); + UUnitAssert.Null(getUrlTask.Result.Error, "Failed to get LogicServerURL"); + UUnitAssert.NotNull(getUrlTask.Result.Result, "Failed to get LogicServerURL"); + UUnitAssert.False(string.IsNullOrEmpty(getUrlTask.Result.Result.Url), "Failed to get LogicServerURL"); + UUnitAssert.False(string.IsNullOrEmpty(PlayFabSettings.LogicServerURL), "Failed to get LogicServerURL"); + } + + var request = new ClientModels.RunCloudScriptRequest(); + request.ActionId = "helloWorld"; + var cloudTask = PlayFabClientAPI.RunCloudScriptAsync(request); + cloudTask.Wait(); + UUnitAssert.Null(cloudTask.Result.Error, "Failed to Execute CloudScript"); + UUnitAssert.NotNull(cloudTask.Result.Result, "Failed to Execute CloudScript"); + UUnitAssert.False(string.IsNullOrEmpty(cloudTask.Result.Result.ResultsEncoded), "Failed to Execute CloudScript"); + + // Get the helloWorld return message + JObject jobj = cloudTask.Result.Result.Results as JObject; + UUnitAssert.NotNull(jobj); + JToken jtok; + jobj.TryGetValue("messageValue", out jtok); + UUnitAssert.NotNull(jtok); + JValue jval = jtok as JValue; + UUnitAssert.NotNull(jval); + string actualMessage = jval.Value as string; + UUnitAssert.Equals("Hello " + playFabId + "!", actualMessage); + } + } +} diff --git a/PlayFabSDK/UnittestRunner/UUnitTestRunner.cs b/PlayFabSDK/UnittestRunner/UUnitTestRunner.cs index 5b8b9b0f..aec4ee57 100644 --- a/PlayFabSDK/UnittestRunner/UUnitTestRunner.cs +++ b/PlayFabSDK/UnittestRunner/UUnitTestRunner.cs @@ -1,48 +1,48 @@ -using PlayFab; -using PlayFab.UUnit; -using System.Reflection; -using System; -using System.IO; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System.Collections.Generic; - -namespace UnittestRunner -{ - class UUnitTestRunner - { - static int Main(string[] args) - { - for (int i = 0; i < args.Length; i++) - { - if (args[i] == "-testInputsFile" && (i + 1) < args.Length) - { - string filename = args[i + 1]; - if (File.Exists(filename)) - { - string testInputsFile = File.ReadAllText(filename); - var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings); - var testInputs = serializer.Deserialize>(new JsonTextReader(new StringReader(testInputsFile))); - PlayFabApiTest.SetTitleInfo(testInputs); - } - else - { - Console.WriteLine("Loading testSettings file failed: " + filename); - Console.WriteLine("From: " + Directory.GetCurrentDirectory()); - } - } - } - - UUnitTestSuite suite = new UUnitTestSuite(); - // With this call, we should only expect the unittests within PlayFabSDK to run - This could be expanded by adding other assemblies manually - foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) - suite.FindAndAddAllTestCases(assembly, typeof(UUnitTestCase)); - - suite.RunAllTests(); - UUnitTestResult result = suite.GetResults(); - Console.WriteLine(result.Summary()); - Console.WriteLine(); - return result.AllTestsPassed() ? 0 : 1; - } - } -} +using PlayFab; +using PlayFab.UUnit; +using System.Reflection; +using System; +using System.IO; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.Collections.Generic; + +namespace UnittestRunner +{ + class UUnitTestRunner + { + static int Main(string[] args) + { + for (int i = 0; i < args.Length; i++) + { + if (args[i] == "-testInputsFile" && (i + 1) < args.Length) + { + string filename = args[i + 1]; + if (File.Exists(filename)) + { + string testInputsFile = File.ReadAllText(filename); + var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings); + var testInputs = serializer.Deserialize>(new JsonTextReader(new StringReader(testInputsFile))); + PlayFabApiTest.SetTitleInfo(testInputs); + } + else + { + Console.WriteLine("Loading testSettings file failed: " + filename); + Console.WriteLine("From: " + Directory.GetCurrentDirectory()); + } + } + } + + UUnitTestSuite suite = new UUnitTestSuite(); + // With this call, we should only expect the unittests within PlayFabSDK to run - This could be expanded by adding other assemblies manually + foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) + suite.FindAndAddAllTestCases(assembly, typeof(UUnitTestCase)); + + suite.RunAllTests(); + UUnitTestResult result = suite.GetResults(); + Console.WriteLine(result.Summary()); + Console.WriteLine(); + return result.AllTestsPassed() ? 0 : 1; + } + } +} diff --git a/PlayFabSDK/UnittestRunner/UnittestRunner.csproj.user b/PlayFabSDK/UnittestRunner/UnittestRunner.csproj.user deleted file mode 100644 index 87ad879c..00000000 --- a/PlayFabSDK/UnittestRunner/UnittestRunner.csproj.user +++ /dev/null @@ -1,16 +0,0 @@ - - - - -testInputsFile C:/depot/PlayFab/pf-main/tools/SDKBuildScripts/testInputs.txt - - - publish\ - - - - - - en-US - false - - \ No newline at end of file diff --git a/PlayFabSDK/source/PlayFabAdminModels.cs b/PlayFabSDK/source/PlayFabAdminModels.cs index 4b789419..fee6a0b4 100644 --- a/PlayFabSDK/source/PlayFabAdminModels.cs +++ b/PlayFabSDK/source/PlayFabAdminModels.cs @@ -2101,6 +2101,11 @@ public class RevokeInventoryItemRequest /// public string PlayFabId { get; set;} + /// + /// Unique PlayFab assigned ID for a specific character owned by a user + /// + public string CharacterId { get; set;} + /// /// unique PlayFab identifier for the item instance to be removed /// diff --git a/PlayFabSDK/source/PlayFabClientAPI.cs b/PlayFabSDK/source/PlayFabClientAPI.cs index 6daf9992..113e3399 100644 --- a/PlayFabSDK/source/PlayFabClientAPI.cs +++ b/PlayFabSDK/source/PlayFabClientAPI.cs @@ -584,7 +584,7 @@ public static async Task> GetPlay } /// - /// Retrieves all requested data for a user in one unified request. By default, this API returns all data for the locally signed-in user. The input parameters may be used to limit the data retrieved any any subset of the available data, as well as retrieve the available data for a different user. Note that certain data, including inventory, virtual currency balances, and personally identifying information, may only be retrieved for the locally signed-in user. In the example below, a request is made for the account details, virtual currency balances, and specified user data for the locally signed-in user. + /// Retrieves all requested data for a user in one unified request. By default, this API returns all data for the locally signed-in user. The input parameters may be used to limit the data retrieved to any subset of the available data, as well as retrieve the available data for a different user. Note that certain data, including inventory, virtual currency balances, and personally identifying information, may only be retrieved for the locally signed-in user. In the example below, a request is made for the account details, virtual currency balances, and specified user data for the locally signed-in user. /// public static async Task> GetUserCombinedInfoAsync(GetUserCombinedInfoRequest request) { diff --git a/PlayFabSDK/source/PlayFabVersion.cs b/PlayFabSDK/source/PlayFabVersion.cs index b485726a..a7552acd 100644 --- a/PlayFabSDK/source/PlayFabVersion.cs +++ b/PlayFabSDK/source/PlayFabVersion.cs @@ -3,7 +3,7 @@ namespace PlayFab.Internal { public class PlayFabVersion { - public static string ApiRevision = "1.5.20150901"; + public static string ApiRevision = "1.6.20150928"; public static string SdkRevision = "1.0.2"; public static string getVersionString() diff --git a/PlayFabSDK/source/Uunit/UUnitAssert.cs b/PlayFabSDK/source/Uunit/UUnitAssert.cs index 8b887f72..f7de7718 100644 --- a/PlayFabSDK/source/Uunit/UUnitAssert.cs +++ b/PlayFabSDK/source/Uunit/UUnitAssert.cs @@ -1,152 +1,109 @@ -/* - * UUnit system from UnityCommunity - * Heavily modified - * 0.4 release by pboechat - * http://wiki.unity3d.com/index.php?title=UUnit - * http://creativecommons.org/licenses/by-sa/3.0/ -*/ - -using System; - -namespace PlayFab.UUnit -{ - public class UUnitAssert - { - public static double DEFAULT_DOUBLE_PRECISION = 0.000001; - - private UUnitAssert() - { - } - - public static void Skip() - { - throw new UUnitSkipException(); - } - - public static void Fail(string message = null) - { - if (string.IsNullOrEmpty(message)) - message = "fail"; - throw new UUnitAssertException(message); - } - - public static void True(bool boolean, string message = null) - { - if (boolean) - { - return; - } - if (string.IsNullOrEmpty(message)) - throw new UUnitAssertException(true, false); - else - throw new UUnitAssertException(true, false, message); - } - - public static void False(bool boolean, string message = null) - { - if (!boolean) - { - return; - } - if (string.IsNullOrEmpty(message)) - throw new UUnitAssertException(true, false); - else - throw new UUnitAssertException(true, false, message); - } - - public static void NotNull(object something, string message = null) - { - if (something != null) - return; // Success - - if (string.IsNullOrEmpty(message)) - message = "Null object"; - throw new UUnitAssertException(message); - } - - public static void Null(object something, string message = null) - { - if (something == null) - return; - - if (string.IsNullOrEmpty(message)) - message = "Not null object"; - throw new UUnitAssertException(message); - } - - public static void Equals(string wanted, string got, string message) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got, message); - } - - public static void Equals(string wanted, string got) - { - if (wanted == got) - return; - throw new UUnitAssertException(wanted, got); - } - - public static void Equals(int wanted, int got, string message) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got, message); - } - - public static void Equals(int wanted, int got) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got); - } - - public static void Equals(double wanted, double got, double precision) - { - if (Math.Abs(wanted - got) < precision) - { - return; - } - throw new UUnitAssertException(wanted, got); - } - - public static void Equals(double wanted, double got) - { - Equals(wanted, got, DEFAULT_DOUBLE_PRECISION); - } - - public static void Equals(char wanted, char got) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got); - } - - public static void Equals(object wanted, object got, string message) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got, message); - } - - public new static void Equals(object wanted, object got) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got); - } - } -} \ No newline at end of file +/* + * UUnit system from UnityCommunity + * Heavily modified + * 0.4 release by pboechat + * http://wiki.unity3d.com/index.php?title=UUnit + * http://creativecommons.org/licenses/by-sa/3.0/ +*/ + +using System; + +namespace PlayFab.UUnit +{ + public static class UUnitAssert + { + public const double DEFAULT_DOUBLE_PRECISION = 0.000001; + + public static void Skip() + { + throw new UUnitSkipException(); + } + + public static void Fail(string message = null) + { + if (string.IsNullOrEmpty(message)) + message = "fail"; + throw new UUnitAssertException(message); + } + + public static void True(bool boolean, string message = null) + { + if (boolean) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: true, Actual: false"; + throw new UUnitAssertException(true, false, message); + } + + public static void False(bool boolean, string message = null) + { + if (!boolean) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: false, Actual: true"; + throw new UUnitAssertException(true, false, message); + } + + public static void NotNull(object something, string message = null) + { + if (something != null) + return; // Success + + if (string.IsNullOrEmpty(message)) + message = "Null object"; + throw new UUnitAssertException(message); + } + + public static void Null(object something, string message = null) + { + if (something == null) + return; + + if (string.IsNullOrEmpty(message)) + message = "Not null object"; + throw new UUnitAssertException(message); + } + + public static void Equals(string wanted, string got, string message = null) + { + if (wanted == got) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: " + wanted + ", Actual: " + got; + throw new UUnitAssertException(wanted, got, message); + } + + public static void Equals(int wanted, int got, string message = null) + { + if (wanted == got) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: " + wanted + ", Actual: " + got; + throw new UUnitAssertException(wanted, got, message); + } + + public static void Equals(double wanted, double got, double precision = DEFAULT_DOUBLE_PRECISION, string message = null) + { + if (Math.Abs(wanted - got) < precision) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: " + wanted + ", Actual: " + got; + throw new UUnitAssertException(wanted, got, message); + } + + public static void Equals(object wanted, object got, string message = null) + { + if (wanted == got) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: " + wanted + ", Actual: " + got; + throw new UUnitAssertException(wanted, got, message); + } + } +} diff --git a/PlayFabSDK/source/Uunit/UUnitAssertException.cs b/PlayFabSDK/source/Uunit/UUnitAssertException.cs index 4c22040d..94ce32f8 100644 --- a/PlayFabSDK/source/Uunit/UUnitAssertException.cs +++ b/PlayFabSDK/source/Uunit/UUnitAssertException.cs @@ -1,50 +1,43 @@ -/* - * UUnit system from UnityCommunity - * Heavily modified - * 0.4 release by pboechat - * http://wiki.unity3d.com/index.php?title=UUnit - * http://creativecommons.org/licenses/by-sa/3.0/ -*/ - -using System; - -namespace PlayFab.UUnit -{ - /// - /// Throw this exception, via UUnitAssert utility function, in order to define when a test has been skipped. - /// The only information shown will be the "skipped" notification - /// - public class UUnitSkipException : Exception { } - - /// - /// Throw this exception, via UUnitAssert utility functions, in order to define when a test has failed. - /// The traceback and message will automatically be displayed as a failure - /// - public class UUnitAssertException : Exception - { - public object expected; - public object received; - public string message; - - public UUnitAssertException(string message) - : base(message) - { - this.message = message; - } - - public UUnitAssertException(object expected, object received, string message) - : base("[UUnit] - Assert Failed - Expected: " + expected + " Received: " + received + "\n\t\t(" + message + ")") - { - this.expected = (expected == null) ? "null" : expected; - this.received = (received == null) ? "null" : received; - this.message = (message == null) ? "" : message; - } - - public UUnitAssertException(object expected, object received) - : base("[UUnit] - Assert Failed - Expected: " + expected + " Received: " + received) - { - this.expected = (expected == null) ? "null" : expected; - this.received = (received == null) ? "null" : received; - } - } -} \ No newline at end of file +/* + * UUnit system from UnityCommunity + * Heavily modified + * 0.4 release by pboechat + * http://wiki.unity3d.com/index.php?title=UUnit + * http://creativecommons.org/licenses/by-sa/3.0/ +*/ + +using System; + +namespace PlayFab.UUnit +{ + /// + /// Throw this exception, via UUnitAssert utility function, in order to define when a test has been skipped. + /// The only information shown will be the "skipped" notification + /// + public class UUnitSkipException : Exception { } + + /// + /// Throw this exception, via UUnitAssert utility functions, in order to define when a test has failed. + /// The traceback and message will automatically be displayed as a failure + /// + public class UUnitAssertException : Exception + { + public object expected; + public object received; + public string message; + + public UUnitAssertException(string message) + : base(message) + { + this.message = message; + } + + public UUnitAssertException(object expected, object received, string message) + : base("[UUnit] - Assert Failed - Expected: " + expected + " Received: " + received + "\n\t\t(" + message + ")") + { + this.expected = (expected == null) ? "null" : expected; + this.received = (received == null) ? "null" : received; + this.message = (message == null) ? "" : message; + } + } +} diff --git a/PlayFabServerSDK/source/PlayFabAdminModels.cs b/PlayFabServerSDK/source/PlayFabAdminModels.cs index 4b789419..fee6a0b4 100644 --- a/PlayFabServerSDK/source/PlayFabAdminModels.cs +++ b/PlayFabServerSDK/source/PlayFabAdminModels.cs @@ -2101,6 +2101,11 @@ public class RevokeInventoryItemRequest /// public string PlayFabId { get; set;} + /// + /// Unique PlayFab assigned ID for a specific character owned by a user + /// + public string CharacterId { get; set;} + /// /// unique PlayFab identifier for the item instance to be removed /// diff --git a/PlayFabServerSDK/source/PlayFabVersion.cs b/PlayFabServerSDK/source/PlayFabVersion.cs index b485726a..a7552acd 100644 --- a/PlayFabServerSDK/source/PlayFabVersion.cs +++ b/PlayFabServerSDK/source/PlayFabVersion.cs @@ -3,7 +3,7 @@ namespace PlayFab.Internal { public class PlayFabVersion { - public static string ApiRevision = "1.5.20150901"; + public static string ApiRevision = "1.6.20150928"; public static string SdkRevision = "1.0.2"; public static string getVersionString() diff --git a/PlayFabServerSDK/source/Uunit/UUnitAssert.cs b/PlayFabServerSDK/source/Uunit/UUnitAssert.cs index 8b887f72..f7de7718 100644 --- a/PlayFabServerSDK/source/Uunit/UUnitAssert.cs +++ b/PlayFabServerSDK/source/Uunit/UUnitAssert.cs @@ -1,152 +1,109 @@ -/* - * UUnit system from UnityCommunity - * Heavily modified - * 0.4 release by pboechat - * http://wiki.unity3d.com/index.php?title=UUnit - * http://creativecommons.org/licenses/by-sa/3.0/ -*/ - -using System; - -namespace PlayFab.UUnit -{ - public class UUnitAssert - { - public static double DEFAULT_DOUBLE_PRECISION = 0.000001; - - private UUnitAssert() - { - } - - public static void Skip() - { - throw new UUnitSkipException(); - } - - public static void Fail(string message = null) - { - if (string.IsNullOrEmpty(message)) - message = "fail"; - throw new UUnitAssertException(message); - } - - public static void True(bool boolean, string message = null) - { - if (boolean) - { - return; - } - if (string.IsNullOrEmpty(message)) - throw new UUnitAssertException(true, false); - else - throw new UUnitAssertException(true, false, message); - } - - public static void False(bool boolean, string message = null) - { - if (!boolean) - { - return; - } - if (string.IsNullOrEmpty(message)) - throw new UUnitAssertException(true, false); - else - throw new UUnitAssertException(true, false, message); - } - - public static void NotNull(object something, string message = null) - { - if (something != null) - return; // Success - - if (string.IsNullOrEmpty(message)) - message = "Null object"; - throw new UUnitAssertException(message); - } - - public static void Null(object something, string message = null) - { - if (something == null) - return; - - if (string.IsNullOrEmpty(message)) - message = "Not null object"; - throw new UUnitAssertException(message); - } - - public static void Equals(string wanted, string got, string message) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got, message); - } - - public static void Equals(string wanted, string got) - { - if (wanted == got) - return; - throw new UUnitAssertException(wanted, got); - } - - public static void Equals(int wanted, int got, string message) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got, message); - } - - public static void Equals(int wanted, int got) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got); - } - - public static void Equals(double wanted, double got, double precision) - { - if (Math.Abs(wanted - got) < precision) - { - return; - } - throw new UUnitAssertException(wanted, got); - } - - public static void Equals(double wanted, double got) - { - Equals(wanted, got, DEFAULT_DOUBLE_PRECISION); - } - - public static void Equals(char wanted, char got) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got); - } - - public static void Equals(object wanted, object got, string message) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got, message); - } - - public new static void Equals(object wanted, object got) - { - if (wanted == got) - { - return; - } - throw new UUnitAssertException(wanted, got); - } - } -} \ No newline at end of file +/* + * UUnit system from UnityCommunity + * Heavily modified + * 0.4 release by pboechat + * http://wiki.unity3d.com/index.php?title=UUnit + * http://creativecommons.org/licenses/by-sa/3.0/ +*/ + +using System; + +namespace PlayFab.UUnit +{ + public static class UUnitAssert + { + public const double DEFAULT_DOUBLE_PRECISION = 0.000001; + + public static void Skip() + { + throw new UUnitSkipException(); + } + + public static void Fail(string message = null) + { + if (string.IsNullOrEmpty(message)) + message = "fail"; + throw new UUnitAssertException(message); + } + + public static void True(bool boolean, string message = null) + { + if (boolean) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: true, Actual: false"; + throw new UUnitAssertException(true, false, message); + } + + public static void False(bool boolean, string message = null) + { + if (!boolean) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: false, Actual: true"; + throw new UUnitAssertException(true, false, message); + } + + public static void NotNull(object something, string message = null) + { + if (something != null) + return; // Success + + if (string.IsNullOrEmpty(message)) + message = "Null object"; + throw new UUnitAssertException(message); + } + + public static void Null(object something, string message = null) + { + if (something == null) + return; + + if (string.IsNullOrEmpty(message)) + message = "Not null object"; + throw new UUnitAssertException(message); + } + + public static void Equals(string wanted, string got, string message = null) + { + if (wanted == got) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: " + wanted + ", Actual: " + got; + throw new UUnitAssertException(wanted, got, message); + } + + public static void Equals(int wanted, int got, string message = null) + { + if (wanted == got) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: " + wanted + ", Actual: " + got; + throw new UUnitAssertException(wanted, got, message); + } + + public static void Equals(double wanted, double got, double precision = DEFAULT_DOUBLE_PRECISION, string message = null) + { + if (Math.Abs(wanted - got) < precision) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: " + wanted + ", Actual: " + got; + throw new UUnitAssertException(wanted, got, message); + } + + public static void Equals(object wanted, object got, string message = null) + { + if (wanted == got) + return; + + if (string.IsNullOrEmpty(message)) + message = "Expected: " + wanted + ", Actual: " + got; + throw new UUnitAssertException(wanted, got, message); + } + } +} diff --git a/PlayFabServerSDK/source/Uunit/UUnitAssertException.cs b/PlayFabServerSDK/source/Uunit/UUnitAssertException.cs index 4c22040d..94ce32f8 100644 --- a/PlayFabServerSDK/source/Uunit/UUnitAssertException.cs +++ b/PlayFabServerSDK/source/Uunit/UUnitAssertException.cs @@ -1,50 +1,43 @@ -/* - * UUnit system from UnityCommunity - * Heavily modified - * 0.4 release by pboechat - * http://wiki.unity3d.com/index.php?title=UUnit - * http://creativecommons.org/licenses/by-sa/3.0/ -*/ - -using System; - -namespace PlayFab.UUnit -{ - /// - /// Throw this exception, via UUnitAssert utility function, in order to define when a test has been skipped. - /// The only information shown will be the "skipped" notification - /// - public class UUnitSkipException : Exception { } - - /// - /// Throw this exception, via UUnitAssert utility functions, in order to define when a test has failed. - /// The traceback and message will automatically be displayed as a failure - /// - public class UUnitAssertException : Exception - { - public object expected; - public object received; - public string message; - - public UUnitAssertException(string message) - : base(message) - { - this.message = message; - } - - public UUnitAssertException(object expected, object received, string message) - : base("[UUnit] - Assert Failed - Expected: " + expected + " Received: " + received + "\n\t\t(" + message + ")") - { - this.expected = (expected == null) ? "null" : expected; - this.received = (received == null) ? "null" : received; - this.message = (message == null) ? "" : message; - } - - public UUnitAssertException(object expected, object received) - : base("[UUnit] - Assert Failed - Expected: " + expected + " Received: " + received) - { - this.expected = (expected == null) ? "null" : expected; - this.received = (received == null) ? "null" : received; - } - } -} \ No newline at end of file +/* + * UUnit system from UnityCommunity + * Heavily modified + * 0.4 release by pboechat + * http://wiki.unity3d.com/index.php?title=UUnit + * http://creativecommons.org/licenses/by-sa/3.0/ +*/ + +using System; + +namespace PlayFab.UUnit +{ + /// + /// Throw this exception, via UUnitAssert utility function, in order to define when a test has been skipped. + /// The only information shown will be the "skipped" notification + /// + public class UUnitSkipException : Exception { } + + /// + /// Throw this exception, via UUnitAssert utility functions, in order to define when a test has failed. + /// The traceback and message will automatically be displayed as a failure + /// + public class UUnitAssertException : Exception + { + public object expected; + public object received; + public string message; + + public UUnitAssertException(string message) + : base(message) + { + this.message = message; + } + + public UUnitAssertException(object expected, object received, string message) + : base("[UUnit] - Assert Failed - Expected: " + expected + " Received: " + received + "\n\t\t(" + message + ")") + { + this.expected = (expected == null) ? "null" : expected; + this.received = (received == null) ? "null" : received; + this.message = (message == null) ? "" : message; + } + } +} diff --git a/README.md b/README.md index 75bcf7f9..f70fbc54 100644 --- a/README.md +++ b/README.md @@ -9,18 +9,18 @@ SDK for C#/.net environments other than Unity, including Microsoft CLR environme ---- * Users should be very familiar with the topics covered in our [getting started guide](https://playfab.com/getting-started). -To connect to the PlayFab service, your machine must be running TLS v1.1 or better. +To connect to the PlayFab service, your machine must be running TLS v1.2 or better. * For Windows, this means Windows 7 and above * [Official Microsoft Documentation](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380516%28v=vs.85%29.aspx) * [Support for SSL/TLS protocols on Windows](http://blogs.msdn.com/b/kaushal/archive/2011/10/02/support-for-ssl-tls-protocols-on-windows.aspx) 3. Source Code & Key Repository Components: ---- -This package contains three different versions of the PlayFab SDK. +This package contains three different versions of the PlayFab SDK. * PlayFabClientSDK - This version contains only client libraries and is designed for integration with your game client * PlayFabServerSDK - Contains server and admin APIs designed to be called from your custom logic server or build process -* PlayFabSDK - Contains all APIs in one SDK +* PlayFabSDK - Contains all APIs in one SDK, as well as a unit-test project #### NuGet @@ -33,7 +33,8 @@ https://www.nuget.org/packages/PlayFabAllSDK/ #### Current Status: [![Build status](https://ci.appveyor.com/api/projects/status/n3aw3s8jpgx9bhbq?svg=true)](https://ci.appveyor.com/project/MattAugustine/csharpsdk-jrl6i) -Full: + +Full: https://playfab-csharp-sdk-builds.s3-us-west-2.amazonaws.com/PlayFabSDK/bin/Release/PlayFabAllSDK.dll https://playfab-csharp-sdk-builds.s3-us-west-2.amazonaws.com/PlayFabSDK/bin/Release/PlayFabAllSDK.pdb @@ -54,8 +55,8 @@ https://playfab-csharp-sdk-builds.s3-us-west-2.amazonaws.com/PlayFabServerSDK/bi For a complete list of available APIs, check out the [online documentation](http://api.playfab.com/Documentation/). #### Contact Us -We love to hear from our developer community! -Do you have ideas on how we can make our products and services better? +We love to hear from our developer community! +Do you have ideas on how we can make our products and services better? Our Developer Success Team can assist with answering any questions as well as process any feedback you have about PlayFab services. @@ -64,13 +65,9 @@ Our Developer Success Team can assist with answering any questions as well as pr 6. Copyright and Licensing Information: ---- - Apache License -- + Apache License -- Version 2.0, January 2004 http://www.apache.org/licenses/ Full details available within the LICENSE file. - -7. Version History: ----- -* (v1.2.4)