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); }
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); }
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); }
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); }
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); }
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); }
/// <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); } }
/// <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; } }
public void GetEntityToken(UUnitTestContext testContext) { var writeTask = PlayFabEntityAPI.GetEntityTokenAsync(new GetEntityTokenRequest(), null, extraHeaders); ContinueWithContext(writeTask, testContext, GetEntityTokenContinued, true, "GetEntityToken failed", true); }
public void GetEntityToken(UUnitTestContext testContext) { var tokenRequest = new GetEntityTokenRequest(); PlayFabEntityAPI.GetEntityToken(tokenRequest, PlayFabUUnitUtils.ApiActionWrapper <GetEntityTokenResponse>(testContext, GetTokenCallback), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext); }
public override void ClassTearDown() { PlayFabEntityAPI.ForgetAllCredentials(); }