Ejemplo n.º 1
0
        public void TestJsonLong()
        {
            var expectedObjects = new JsonNumTestContainer[] {
                // URGENT TODO: This test fails for long.MaxValue - Write custom serializers for ulongs that can handle larger values
                new JsonNumTestContainer {
                    IntValue = int.MaxValue, UintValue = uint.MaxValue, LongValue = long.MaxValue, UlongValue = long.MaxValue, FloatValue = float.MaxValue, DoubleValue = double.MaxValue
                },
                new JsonNumTestContainer {
                    IntValue = int.MinValue, UintValue = uint.MinValue, LongValue = long.MinValue, UlongValue = ulong.MinValue, FloatValue = float.MinValue, DoubleValue = double.MinValue
                },
                new JsonNumTestContainer {
                    IntValue = 0, UintValue = 0, LongValue = 0, UlongValue = 0, FloatValue = 0, DoubleValue = 0
                },
            };

            for (int i = 0; i < expectedObjects.Length; i++)
            {
                // Convert the object to json and back, and verify that everything is the same
                var actualJson   = JsonConvert.SerializeObject(expectedObjects[i], Util.JsonFormatting, Util.JsonSettings).Replace(" ", "").Replace("\n", "").Replace("\r", "").Replace("\t", "");
                var actualObject = JsonConvert.DeserializeObject <JsonNumTestContainer>(actualJson, Util.JsonSettings);

                UUnitAssert.IntEquals(expectedObjects[i].IntValue, actualObject.IntValue);
                UUnitAssert.UintEquals(expectedObjects[i].UintValue, actualObject.UintValue);
                UUnitAssert.LongEquals(expectedObjects[i].LongValue, actualObject.LongValue);
                UUnitAssert.ULongEquals(expectedObjects[i].UlongValue, actualObject.UlongValue);
                UUnitAssert.FloatEquals(expectedObjects[i].FloatValue, actualObject.FloatValue, 0.001f);
                UUnitAssert.DoubleEquals(expectedObjects[i].DoubleValue, actualObject.DoubleValue, 0.001);
            }
        }
Ejemplo n.º 2
0
 public void TestStaticCallbacks_GeneralOnly()
 {
     EventStaticListener.Register();
     callbacks.Clear();
     PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest {
         CreateAccount = true, CustomId = "UnitySdk-UnitTest", TitleId = "6195"
     }, null, null);
     UUnitAssert.True(callbacks.Contains("OnRequest_StaticGl"), string.Join(", ", callbacks.ToArray()));
     UUnitAssert.True(callbacks.Contains("OnRequest_StaticLogin"), string.Join(", ", callbacks.ToArray()));
     UUnitAssert.IntEquals(2, callbacks.Count, string.Join(", ", callbacks.ToArray()));
     callbacks.Clear();
     WaitForApiCalls();
     UUnitAssert.True(callbacks.Contains("OnResponse_StaticGl"), string.Join(", ", callbacks.ToArray()));
     UUnitAssert.True(callbacks.Contains("OnResponse_StaticLogin"), string.Join(", ", callbacks.ToArray()));
     UUnitAssert.IntEquals(2, callbacks.Count, string.Join(", ", callbacks.ToArray()));
     EventStaticListener.Unregister();
 }
Ejemplo n.º 3
0
        public void TestInstCallbacks_LocalCallback()
        {
            var listener = new EventInstanceListener();

            listener.Register();
            callbacks.Clear();
            PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest {
                CreateAccount = true, CustomId = "UnitySdk-UnitTest", TitleId = "6195"
            }, OnSuccessLocal, null);
            UUnitAssert.True(callbacks.Contains("OnRequest_InstGl"), string.Join(", ", callbacks.ToArray()));
            UUnitAssert.True(callbacks.Contains("OnRequest_InstLogin"), string.Join(", ", callbacks.ToArray()));
            UUnitAssert.IntEquals(2, callbacks.Count, string.Join(", ", callbacks.ToArray()));
            callbacks.Clear();
            WaitForApiCalls();
            UUnitAssert.True(callbacks.Contains("OnResponse_InstGl"), string.Join(", ", callbacks.ToArray()));
            UUnitAssert.True(callbacks.Contains("OnResponse_InstLogin"), string.Join(", ", callbacks.ToArray()));
            UUnitAssert.True(callbacks.Contains("OnSuccessLocal"), string.Join(", ", callbacks.ToArray()));
            UUnitAssert.IntEquals(3, callbacks.Count, string.Join(", ", callbacks.ToArray()));
            listener.Unregister();
        }
Ejemplo n.º 4
0
        public void TestCallbackFailures()
        {
            PlayFabSettings.HideCallbackErrors = true;
            // Just need any valid auth token for this test
            LoginWithCustomIDRequest loginRequest = new LoginWithCustomIDRequest();

            loginRequest.CreateAccount = true;
            loginRequest.CustomId      = "Custom ID";        //SystemInfo.deviceUniqueIdentifier;
            PlayFabClientAPI.LoginWithCustomID(loginRequest, null, null);
            WaitForApiCalls();

            PlayFabSettings.RegisterForResponses(null, (PlayFabSettings.ResponseCallback <object, PlayFabResultCommon>)SuccessCallback_Global);
            PlayFabSettings.GlobalErrorHandler += SharedError_Global;
            callbacks.Clear();

            GetCatalogItemsRequest catalogRequest = new GetCatalogItemsRequest();

            PlayFabClientAPI.GetCatalogItems(catalogRequest, GetCatalogItemsCallback_Single, SharedError_Single);
            WaitForApiCalls();
            UUnitAssert.True(callbacks.Contains("GetCatalogItemsCallback_Single"), "GetCatalogItemsCallback_Single"); // All success callbacks should occur, even if some throw exceptions
            UUnitAssert.True(callbacks.Contains("SuccessCallback_Global"), "SuccessCallback_Global");                 // All success callbacks should occur, even if some throw exceptions
            UUnitAssert.False(callbacks.Contains("SharedError_Single"), "SharedError_Single");                        // Successful calls should not invoke error-callbacks (even when callbacks throw exceptions)
            UUnitAssert.False(callbacks.Contains("SharedError_Global"), "SharedError_Global");                        // Successful calls should not invoke error-callbacks (even when callbacks throw exceptions)
            UUnitAssert.IntEquals(2, callbacks.Count);
            callbacks.Clear();

            RegisterPlayFabUserRequest registerRequest = new RegisterPlayFabUserRequest();

            PlayFabClientAPI.RegisterPlayFabUser(registerRequest, RegisterPlayFabUserCallback_Single, SharedError_Single);
            WaitForApiCalls();
            UUnitAssert.False(callbacks.Contains("GetCatalogItemsCallback_Single"), "GetCatalogItemsCallback_Single"); // Success should not have occurred
            UUnitAssert.False(callbacks.Contains("SuccessCallback_Global"), "SuccessCallback_Global");                 // Success should not have occurred
            UUnitAssert.True(callbacks.Contains("SharedError_Single"), "SharedError_Single");                          // All error callbacks should occur, even if some throw exceptions
            UUnitAssert.True(callbacks.Contains("SharedError_Global"), "SharedError_Global");                          // All error callbacks should occur, even if some throw exceptions
            UUnitAssert.IntEquals(2, callbacks.Count);
            callbacks.Clear();
            PlayFabSettings.HideCallbackErrors = false;
            PlayFabSettings.ForceUnregisterAll();
        }