Esempio n. 1
0
        private void GetObjectCallback1(GetObjectsResponse result)
        {
            var testContext = (UUnitTestContext)result.CustomData;

            _testInteger = 0; // Default if the data isn't present
            foreach (var eachObjPair in result.Objects)
            {
                if (eachObjPair.Key == TEST_OBJ_NAME)
                {
                    int.TryParse(eachObjPair.Value.EscapedDataObject, out _testInteger);
                }
            }

            _testInteger = (_testInteger + 1) % 100; // This test is about the Expected value changing - but not testing more complicated issues like bounds

            var updateRequest = new SetObjectsRequest
            {
                Entity  = _entityKey,
                Objects = new List <SetObject> {
                    new SetObject {
                        ObjectName = TEST_OBJ_NAME, DataObject = _testInteger
                    }
                }
            };

            PlayFabEntityAPI.SetObjects(updateRequest, PlayFabUUnitUtils.ApiActionWrapper <SetObjectsResponse>(testContext, UpdateObjectCallback), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
Esempio n. 2
0
        private void GetObjects1Continued(PlayFabResult <GetObjectsResponse> result, UUnitTestContext testContext, string failMessage)
        {
            // testContext.IntEquals(result.Result.Objects.Count, 1);
            // testContext.StringEquals(result.Result.Objects[0].ObjectName, TEST_DATA_KEY);

            _testInteger = 0;
            if (result.Result.Objects.Count == 1 && result.Result.Objects[TEST_DATA_KEY].ObjectName == TEST_DATA_KEY)
            {
                int.TryParse(result.Result.Objects[TEST_DATA_KEY].EscapedDataObject, out _testInteger);
            }

            var request = new SetObjectsRequest
            {
                Entity  = entityKey,
                Objects = new List <SetObject>
                {
                    new SetObject
                    {
                        DataObject = _testInteger,
                        ObjectName = TEST_DATA_KEY
                    }
                }
            };
            var eachTask = PlayFabEntityAPI.SetObjectsAsync(request, null, extraHeaders);

            ContinueWithContext(eachTask, testContext, SetObjectsContinued, true, "SetObjects failed", false);
        }
Esempio n. 3
0
        public void ObjectApi(UUnitTestContext testContext)
        {
            var getRequest = new GetObjectsRequest {
                Entity = _entityKey, EscapeObject = true
            };

            PlayFabEntityAPI.GetObjects(getRequest, PlayFabUUnitUtils.ApiActionWrapper <GetObjectsResponse>(testContext, GetObjectCallback1), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
Esempio n. 4
0
        private void UpdateObjectCallback(SetObjectsResponse result)
        {
            var testContext = (UUnitTestContext)result.CustomData;

            var getRequest = new GetObjectsRequest {
                Entity = _entityKey, EscapeObject = true
            };

            PlayFabEntityAPI.GetObjects(getRequest, PlayFabUUnitUtils.ApiActionWrapper <GetObjectsResponse>(testContext, GetObjectCallback2), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
Esempio n. 5
0
        private void SetObjectsContinued(PlayFabResult <SetObjectsResponse> result, UUnitTestContext testContext, string failMessage)
        {
            var request = new GetObjectsRequest
            {
                Entity       = entityKey,
                EscapeObject = true
            };
            var eachTask = PlayFabEntityAPI.GetObjectsAsync(request, null, extraHeaders);

            ContinueWithContext(eachTask, testContext, GetObjects2Continued, true, "GetObjects2 failed", false);
        }
Esempio n. 6
0
        public void ObjectApi(UUnitTestContext testContext)
        {
            var request = new GetObjectsRequest
            {
                Entity       = entityKey,
                EscapeObject = true
            };
            var eachTask = PlayFabEntityAPI.GetObjectsAsync(request, null, extraHeaders);

            ContinueWithContext(eachTask, testContext, GetObjects1Continued, true, "GetObjects1 failed", false);
        }
Esempio n. 7
0
        /// <summary>
        /// Sends events to server.
        /// </summary>
        public void Send()
        {
            if (PlayFabClientAPI.IsClientLoggedIn())
            {
                int eventsInTheBatch       = 0;
                WriteEventsRequest request = new WriteEventsRequest();
                request.Events            = new List <EventContents>();
                request.FlushToPlayStream = true;

                while ((eventsRequests.Count > 0) && (eventsInTheBatch < maxBatchSizeInEvents))
                {
                    EventContents eventInfo = eventsRequests.Dequeue();
                    request.Events.Add(eventInfo);

                    eventsInTheBatch++;
                }

                PlayFabEntityAPI.WriteEvents(request, EventSentSuccessfulCallback, EventSentErrorCallback);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Sends events to server.
        /// </summary>
        public void Send()
        {
            if ((PlayFabClientAPI.IsClientLoggedIn()) && (isSending == false))
            {
                isSending = true;

                WriteEventsRequest request = new WriteEventsRequest();
                request.Events = new List <EventContents>();

                while ((eventsRequests.Count > 0) && (request.Events.Count < maxBatchSizeInEvents))
                {
                    EventContents eventInfo = eventsRequests.Dequeue();
                    request.Events.Add(eventInfo);
                }

                if (request.Events.Count > 0)
                {
                    PlayFabEntityAPI.WriteEvents(request, EventSentSuccessfulCallback, EventSentErrorCallback);
                }

                isSending = false;
            }
        }
Esempio n. 9
0
        public void GetEntityToken(UUnitTestContext testContext)
        {
            var writeTask = PlayFabEntityAPI.GetEntityTokenAsync(new GetEntityTokenRequest(), null, extraHeaders);

            ContinueWithContext(writeTask, testContext, GetEntityTokenContinued, true, "GetEntityToken failed", true);
        }
Esempio n. 10
0
        public void GetEntityToken(UUnitTestContext testContext)
        {
            var tokenRequest = new GetEntityTokenRequest();

            PlayFabEntityAPI.GetEntityToken(tokenRequest, PlayFabUUnitUtils.ApiActionWrapper <GetEntityTokenResponse>(testContext, GetTokenCallback), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
Esempio n. 11
0
 public override void ClassTearDown()
 {
     PlayFabEntityAPI.ForgetAllCredentials();
 }