Ejemplo n.º 1
0
 public override void SetUp(UUnitTestContext testContext)
 {
     if (!TITLE_INFO_SET)
     {
         testContext.Skip(); // We cannot do client tests if the titleId is not given
     }
 }
Ejemplo n.º 2
0
        public override void SetUp(UUnitTestContext testContext)
        {
            if (_execOnce)
            {
                Dictionary <string, string> testInputs;
                if (File.Exists(TitleDataFilename))
                {
                    var testInputsFile = PlayFabUtil.ReadAllFileText(TitleDataFilename);
                    testInputs = JsonWrapper.DeserializeObject <Dictionary <string, string> >(testInputsFile, PlayFabUtil.ApiSerializerStrategy);
                }
                else
                {
                    // NOTE FOR DEVELOPERS: if you want to run these tests, provide useful defaults, and uncomment this section, or provide a valid path to a "testTitleData.json" file above
                    testInputs = new Dictionary <string, string>();
                    //Debug.LogError("Loading testSettings file failed: " + filename + ", loading defaults.");
                    //testInputs["titleId"] = "your title id here";
                    //testInputs["developerSecretKey"] = "your secret key here"; // BE VERY CAREFUL NOT TO PUBLISH THIS, or build it into a client
                }
                SetTitleInfo(testInputs);
                _execOnce = false;
            }

            if (!_titleInfoSet)
            {
                testContext.Skip(); // We cannot do client tests if the titleId is not given
            }
        }
Ejemplo n.º 3
0
        public void MultiplePlayerApiCall(UUnitTestContext testContext)
        {
            if (authenticationContext1?.ClientSessionTicket == null || authenticationContext2?.ClientSessionTicket == null)
            {
                testContext.Skip("To run this test MultipleLoginWithStaticMethods test should be passed and store authenticationContext values");
            }

            var getPlayerProfileRequest = new GetPlayerProfileRequest()
            {
                AuthenticationContext = authenticationContext1,
                PlayFabId             = authenticationContext1.PlayFabId
            };
            var getPlayerProfileRequest2 = new GetPlayerProfileRequest()
            {
                AuthenticationContext = authenticationContext2,
                PlayFabId             = authenticationContext2.PlayFabId
            };

            var getPlayerProfileTask  = clientApi.GetPlayerProfileAsync(getPlayerProfileRequest, null, testTitleData.extraHeaders).Result;
            var getPlayerProfileTask2 = clientApi.GetPlayerProfileAsync(getPlayerProfileRequest2, null, testTitleData.extraHeaders).Result;

            testContext.NotNull(getPlayerProfileTask.Result, "GetPlayerProfile Failed for getPlayerProfileRequest");
            testContext.NotNull(getPlayerProfileTask2.Result, "GetPlayerProfile Failed for getPlayerProfileRequest2");
            testContext.IsNull(getPlayerProfileTask.Error, "GetPlayerProfile error occured for getPlayerProfileRequest: " + getPlayerProfileTask.Error?.ErrorMessage ?? string.Empty);
            testContext.IsNull(getPlayerProfileTask2.Error, "GetPlayerProfile error occured for getPlayerProfileRequest2: " + getPlayerProfileTask2.Error?.ErrorMessage ?? string.Empty);

            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
Ejemplo n.º 4
0
        public override void SetUp(UUnitTestContext testContext)
        {
            if (EXEC_ONCE)
            {
                Dictionary <string, string> testInputs;
                string filename = "C:/depot/pf-main/tools/SDKBuildScripts/testTitleData.json"; // TODO: Figure out how to not hard code this
                if (File.Exists(filename))
                {
                    string testInputsFile = PlayFabUtil.ReadAllFileText(filename);

                    testInputs = JsonWrapper.DeserializeObject <Dictionary <string, string> >(testInputsFile, PlayFabUtil.ApiSerializerStrategy);
                }
                else
                {
                    // NOTE FOR DEVELOPERS: if you want to run these tests, provide useful defaults, and uncomment this section, or provide a valid path to a "testTitleData.json" file above
                    testInputs = new Dictionary <string, string>();
                    //Debug.LogError("Loading testSettings file failed: " + filename + ", loading defaults.");
                    //testInputs["titleId"] = "your title id here";
                    //testInputs["titleCanUpdateSettings"] = "true"; // These tests require a GameManager setting: clients must be able to set stats and userData
                    //testInputs["userName"] = "******";
                    //testInputs["userEmail"] = "*****@*****.**";
                    //testInputs["userPassword"] = "******";
                }
                SetTitleInfo(testInputs);
                EXEC_ONCE = false;
            }

            if (!TITLE_INFO_SET)
            {
                testContext.Skip(); // We cannot do client tests if the titleId is not given
            }
        }
Ejemplo n.º 5
0
        public override void SetUp(UUnitTestContext testContext)
        {
            if (EXEC_ONCE)
            {
                Dictionary <string, string> testInputs;
                string filename = "C:/depot/pf-main/tools/SDKBuildScripts/testTitleData.json"; // TODO: Figure out how to not hard code this
                if (File.Exists(filename))
                {
                    string testInputsFile = PlayFabUtil.ReadAllFileText(filename);

                    testInputs = JsonWrapper.DeserializeObject <Dictionary <string, string> >(testInputsFile, PlayFabUtil.ApiSerializerStrategy);
                }
                else
                {
                    Debug.LogError("Loading testSettings file failed: " + filename + ", loading defaults.");
                    testInputs            = new Dictionary <String, String>();
                    testInputs["titleId"] = "6195";
                    testInputs["titleCanUpdateSettings"] = "true";
                    testInputs["userName"]     = "******";
                    testInputs["userEmail"]    = "*****@*****.**";
                    testInputs["userPassword"] = "******";
                }
                SetTitleInfo(testInputs);
                EXEC_ONCE = false;
            }

            if (!TITLE_INFO_SET)
            {
                testContext.Skip(); // We cannot do client tests if the titleId is not given
            }
        }
Ejemplo n.º 6
0
 public override void SetUp(UUnitTestContext testContext)
 {
     maxRetry = 1;
     // Verify all the inputs won't cause crashes in the tests
     if (string.IsNullOrEmpty(clientSettings.TitleId))
     {
         testContext.Skip(); // We cannot do client tests if the titleId is not given
     }
 }
Ejemplo n.º 7
0
        public override void SetUp(UUnitTestContext testContext)
        {
            // Verify all the inputs won't cause crashes in the tests
            var titleInfoSet = !string.IsNullOrEmpty(clientSettings.TitleId) && !string.IsNullOrEmpty(_userEmail);

            if (!titleInfoSet)
            {
                testContext.Skip(); // We cannot do client tests if the titleId is not given
            }
        }
Ejemplo n.º 8
0
        public override void SetUp(UUnitTestContext testContext)
        {
            testTitleData                      = TestTitleDataLoader.LoadTestTitleData();
            PlayFabSettings.TitleId            = testTitleData.titleId;
            PlayFabSettings.DeveloperSecretKey = testTitleData.developerSecretKey;

            // Verify all the inputs won't cause crashes in the tests
            var titleInfoSet = !string.IsNullOrEmpty(PlayFabSettings.TitleId) && !string.IsNullOrEmpty(PlayFabSettings.DeveloperSecretKey);

            if (!titleInfoSet)
            {
                testContext.Skip(); // We cannot do client tests if the titleId is not given
            }
        }
        public override void SetUp(UUnitTestContext testContext)
        {
            PlayFabSettings.staticSettings.ConnectionString = testTitleData.connectionString;

            authApi   = new PlayFabAuthenticationInstanceAPI(PlayFabSettings.staticSettings, PlayFabSettings.staticPlayer);
            clientApi = new PlayFabClientInstanceAPI(PlayFabSettings.staticSettings, PlayFabSettings.staticPlayer);
            dataApi   = new PlayFabDataInstanceAPI(PlayFabSettings.staticSettings, PlayFabSettings.staticPlayer);

            maxRetry = 1;
            if (!TITLE_INFO_SET)
            {
                testContext.Skip(); // We cannot do client tests if the titleId is not given
            }
        }
Ejemplo n.º 10
0
        public void InvalidLogin(UUnitTestContext testContext)
        {
            if (string.IsNullOrEmpty(_userEmail))
            {
                testContext.Skip(); // We need additional information to attempt this test
            }
            // If the setup failed to log in a user, we need to create one.
            var request = new LoginWithEmailAddressRequest
            {
                Email    = _userEmail,
                Password = "******",
            };

            clientInstance.LoginWithEmailAddress(request, PlayFabUUnitUtils.ApiActionWrapper <LoginResult>(testContext, InvalidLoginCallback), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, ExpectedLoginErrorCallback), testContext);
        }
Ejemplo n.º 11
0
        public override void SetUp(UUnitTestContext testContext)
        {
            testTitleData = TestTitleDataLoader.LoadTestTitleData();

            // Verify all the inputs won't cause crashes in the tests
            var titleInfoSet = !string.IsNullOrEmpty(PlayFabSettings.TitleId);

            if (!titleInfoSet)
            {
                testContext.Skip(); // We cannot do client tests if the titleId is not given
            }
            if (testTitleData.extraHeaders != null)
            {
                foreach (var pair in testTitleData.extraHeaders)
                {
                    PlayFabHttp.GlobalHeaderInjection[pair.Key] = pair.Value;
                }
            }
        }
Ejemplo n.º 12
0
        public override void SetUp(UUnitTestContext testContext)
        {
            if (_execOnce)
            {
                Dictionary <string, string> testInputs;
                var filename = "testTitleData.json"; // default to local file if PF_TEST_TITLE_DATA_JSON env-var does not exist

#if UNITY_STANDALONE_WIN
                // Prefer to load path from environment variable, if present
                var tempFilename = Environment.GetEnvironmentVariable("PF_TEST_TITLE_DATA_JSON");
                if (!string.IsNullOrEmpty(tempFilename))
                {
                    filename = tempFilename;
                }
#endif

                if (File.Exists(filename))
                {
                    var testInputsFile = PlayFabUtil.ReadAllFileText(filename);

                    testInputs = JsonWrapper.DeserializeObject <Dictionary <string, string> >(testInputsFile);
                }
                else
                {
                    // NOTE FOR DEVELOPERS: POPULATE THIS SECTION WITH REAL INFORMATION (or set up a testTitleData file, and set your PF_TEST_TITLE_DATA_JSON to the path for that file)
                    testInputs = new Dictionary <string, string>();
                    //Debug.LogError("Loading testSettings file failed: " + filename + ", loading defaults.");
                    //testInputs["titleId"] = "your title id here";
                    //testInputs["developerSecretKey"] = "your secret key here"; // BE VERY CAREFUL NOT TO PUBLISH THIS, or build it into a client
                }
                SetTitleInfo(testInputs);
                _execOnce = false;
            }

            if (!_titleInfoSet)
            {
                testContext.Skip(); // We cannot do client tests if the titleId is not given
            }
        }
Ejemplo n.º 13
0
        public override void SetUp(UUnitTestContext testContext)
        {
#if !UNITY_WSA && !UNITY_WP8
            PlayFabWebRequest.SkipCertificateValidation(); // Internal testing doesn't have a good answer for this yet
#endif
            testTitleData = TestTitleDataLoader.LoadTestTitleData();
            _userEmail    = testTitleData.userEmail;

            // Verify all the inputs won't cause crashes in the tests
            var titleInfoSet = !string.IsNullOrEmpty(PlayFabSettings.TitleId) && !string.IsNullOrEmpty(_userEmail);
            if (!titleInfoSet)
            {
                testContext.Skip(); // We cannot do client tests if the titleId is not given
            }
            if (testTitleData.extraHeaders != null)
            {
                foreach (var pair in testTitleData.extraHeaders)
                {
                    PlayFabHttp.GlobalHeaderInjection[pair.Key] = pair.Value;
                }
            }
        }
Ejemplo n.º 14
0
        public void AsyncApiCallWithMultipleUser(UUnitTestContext testContext)
        {
            if (authenticationContext1?.ClientSessionTicket == null || authenticationContext2?.ClientSessionTicket == null || authenticationContext3?.ClientSessionTicket == null)
            {
                testContext.Skip("To run this test MultipleLoginWithStaticMethods test should be passed and store authenticationContext values");
            }

            var task1 = clientApi.GetUserDataAsync(new GetUserDataRequest()
            {
                AuthenticationContext = authenticationContext1
            }, null, testTitleData.extraHeaders);
            var task2 = clientApi.GetUserDataAsync(new GetUserDataRequest()
            {
                AuthenticationContext = authenticationContext2
            }, null, testTitleData.extraHeaders);
            var task3 = clientApi.GetUserDataAsync(new GetUserDataRequest()
            {
                AuthenticationContext = authenticationContext3
            }, null, testTitleData.extraHeaders);

            var tasks = new List <Task>()
            {
                task1, task2, task3
            };

            Task.WhenAll(tasks).ContinueWith(whenAll =>
            {
                if (!whenAll.IsCanceled && !whenAll.IsFaulted)
                {
                    testContext.EndTest(UUnitFinishState.PASSED, null);
                }
                else
                {
                    testContext.Fail("Async failed " + whenAll.Exception.Flatten().Message);
                }
            });
        }