public void CheckWithAuthContextAndWithoutAuthContext(UUnitTestContext testContext) { PlayFabSettings.DeveloperSecretKey = testTitleData.developerSecretKey; //IT will use static developer key - Should has no error PlayFabServerInstanceAPI serverInstance1 = new PlayFabServerInstanceAPI(); var result = serverInstance1.GetAllSegmentsAsync(new GetAllSegmentsRequest()).Result; PlayFabAuthenticationContext context = new PlayFabAuthenticationContext(); context.DeveloperSecretKey = "WRONGKEYTOFAIL"; //IT will use context developer key - Should has error because of wrong key PlayFabServerInstanceAPI serverInstance2 = new PlayFabServerInstanceAPI(context); var result2 = serverInstance2.GetAllSegmentsAsync(new GetAllSegmentsRequest()).Result; try { testContext.NotNull(result.Result, "Server Instance1 result is null"); testContext.IsNull(result.Error, "Server Instance1 result got error message : " + result.Error?.ErrorMessage ?? string.Empty); testContext.IsNull(result2.Result, "Server Instance2 result is not null"); testContext.NotNull(result2.Error, "Server Instance2 got no error message"); testContext.IntEquals(401, result2.Error.HttpCode, "Server Instance2 got wrong error"); testContext.EndTest(UUnitFinishState.PASSED, null); } catch (Exception ex) { testContext.Fail("CheckWithAuthContextAndWithoutAuthContext failed : " + ex.Message); } }
public void CheckWithNoSettings(UUnitTestContext testContext) { PlayFabSettings.staticSettings.DeveloperSecretKey = testTitleData.developerSecretKey; //It should work with static class only PlayFabServerInstanceAPI serverInstanceWithoutAnyParameter = new PlayFabServerInstanceAPI(); var getAllSegmentsTask = serverInstanceWithoutAnyParameter.GetAllSegmentsAsync(new GetAllSegmentsRequest()); ContinueWithContext(getAllSegmentsTask, testContext, null, false, "Work with no settings failed", true); }
public void CheckWithAuthContextAndWithoutAuthContext(UUnitTestContext testContext) { PlayFabSettings.staticSettings.TitleId = testTitleData.titleId; PlayFabSettings.staticSettings.DeveloperSecretKey = testTitleData.developerSecretKey; //IT will use static developer key - Should has no error PlayFabServerInstanceAPI serverInstance1 = new PlayFabServerInstanceAPI(); //IT will use context developer key - Should has error because of wrong key PlayFabApiSettings settings2 = new PlayFabApiSettings(); settings2.TitleId = testTitleData.titleId; settings2.DeveloperSecretKey = "WRONGKEYTOFAIL"; PlayFabServerInstanceAPI serverInstance2 = new PlayFabServerInstanceAPI(settings2); PlayFabResult <GetAllSegmentsResult> result1, result2; try { result1 = serverInstance1.GetAllSegmentsAsync(new GetAllSegmentsRequest()).Result; result2 = serverInstance2.GetAllSegmentsAsync(new GetAllSegmentsRequest()).Result; } catch (AggregateException e) { throw e.InnerException; } testContext.IsNull(result1.Error, result1?.Error?.GenerateErrorReport()); testContext.NotNull(result1.Result, "Server Instance1 result is null"); testContext.NotNull(result2.Error, result2?.Error?.GenerateErrorReport()); testContext.IsNull(result2.Result, result2?.Error?.GenerateErrorReport()); testContext.IntEquals(401, result2.Error.HttpCode, "Server Instance2 got wrong error"); testContext.EndTest(UUnitFinishState.PASSED, null); }
public void ParallelRequest(UUnitTestContext testContext) { List <Task> tasks = new List <Task>(); PlayFabApiSettings settings1 = new PlayFabApiSettings(); settings1.TitleId = testTitleData.titleId; settings1.DeveloperSecretKey = testTitleData.developerSecretKey; PlayFabApiSettings settings2 = new PlayFabApiSettings(); settings2.TitleId = testTitleData.titleId; settings2.DeveloperSecretKey = "GETERROR"; PlayFabApiSettings settings3 = new PlayFabApiSettings(); settings3.TitleId = testTitleData.titleId; settings3.DeveloperSecretKey = testTitleData.developerSecretKey; PlayFabApiSettings settings4 = new PlayFabApiSettings(); settings4.TitleId = testTitleData.titleId; settings4.DeveloperSecretKey = "TESTKEYERROR"; PlayFabApiSettings settings5 = new PlayFabApiSettings(); settings5.TitleId = testTitleData.titleId; settings5.DeveloperSecretKey = "123421"; PlayFabServerInstanceAPI serverInstance1 = new PlayFabServerInstanceAPI(settings1); tasks.Add(serverInstance1.GetAllSegmentsAsync(new GetAllSegmentsRequest())); PlayFabServerInstanceAPI serverInstance2 = new PlayFabServerInstanceAPI(settings2); tasks.Add(serverInstance2.GetAllSegmentsAsync(new GetAllSegmentsRequest())); PlayFabServerInstanceAPI serverInstance3 = new PlayFabServerInstanceAPI(settings3); tasks.Add(serverInstance3.GetAllSegmentsAsync(new GetAllSegmentsRequest())); PlayFabServerInstanceAPI serverInstance4 = new PlayFabServerInstanceAPI(settings4); tasks.Add(serverInstance4.GetAllSegmentsAsync(new GetAllSegmentsRequest())); PlayFabServerInstanceAPI serverInstance5 = new PlayFabServerInstanceAPI(settings5); tasks.Add(serverInstance5.GetAllSegmentsAsync(new GetAllSegmentsRequest())); Task.WhenAll(tasks).ContinueWith(whenAll => { if (!whenAll.IsCanceled && !whenAll.IsFaulted) { testContext.EndTest(UUnitFinishState.PASSED, null); } else { testContext.Fail("Parallel Requests failed " + whenAll.Exception.Flatten().Message); } }); }