public void SerializeExample(UUnitTestContext testContext) { TestSuiteReport[] actualSuites = JsonWrapper.DeserializeObject <TestSuiteReport[]>(EXAMPLE_JSON); testContext.NotNull(actualSuites); foreach (var expectedTestName in EXPECTED_TESTS) { var testFound = false; foreach (var suite in actualSuites) { foreach (var test in suite.testResults) { if (test.name == expectedTestName) { testFound = true; break; } } testContext.IntEquals(suite.tests, EXPECTED_TESTS.Length, "Total tests does not match expected {0}, {1}"); } testContext.True(testFound, "Test not found: " + expectedTestName); } testContext.EndTest(UUnitFinishState.PASSED, null); }
public void XmlReadWriteSequence(UUnitTestContext testContext) { List <TestSuiteReport> xmlReport = JUnitXml.ParseXmlFile(_tempFileFullPath); JUnitXml.WriteXmlFile(_tempFileFullPath, xmlReport, true); List <TestSuiteReport> xmlReport2 = JUnitXml.ParseXmlFile(_tempFileFullPath); testContext.IntEquals(xmlReport.Count, xmlReport2.Count); testContext.EndTest(UUnitFinishState.PASSED, null); }
public void PassWithMessageJson(UUnitTestContext testContext) { var readFileName = Path.GetFullPath("../../testPassWithMessage.json"); testContext.True(File.Exists(readFileName), readFileName); var json = File.ReadAllText(readFileName); List <TestSuiteReport> testReport = JsonWrapper.DeserializeObject <List <TestSuiteReport> >(json); testContext.IntEquals(1, testReport.Count); foreach (var eachReport in testReport) { testContext.IntEquals(0, eachReport.failures); testContext.IntEquals(0, eachReport.skipped); testContext.NotNull(eachReport.testResults); foreach (var eachTest in eachReport.testResults) { testContext.True(eachTest.IsXmlSingleLine()); } } testContext.EndTest(UUnitFinishState.PASSED, null); }
public void PassWithMessageXml(UUnitTestContext testContext) { var readFileName = Path.GetFullPath("../../testPassWithMessage.xml"); testContext.True(File.Exists(readFileName), readFileName); List <TestSuiteReport> inputReport = JUnitXml.ParseXmlFile(readFileName); JUnitXml.WriteXmlFile(_tempFileFullPath, inputReport, true); List <TestSuiteReport> testReport = JUnitXml.ParseXmlFile(_tempFileFullPath); testContext.IntEquals(1, testReport.Count); foreach (var eachReport in testReport) { testContext.IntEquals(0, eachReport.failures); testContext.IntEquals(0, eachReport.skipped); testContext.NotNull(eachReport.testResults); foreach (var eachTest in eachReport.testResults) { testContext.True(eachTest.IsXmlSingleLine()); } } testContext.EndTest(UUnitFinishState.PASSED, null); }
public void TestInstCallbacks_GeneralOnly(UUnitTestContext testContext) { _listener.Register(); PlayFabHttp.ApiProcessingEventHandler += TestInstCallbacks_GeneralOnly_OnGlobalEventHandler; var request = new LoginWithCustomIDRequest { CreateAccount = true, CustomId = PlayFabSettings.BuildIdentifier, TitleId = "6195" }; PlayFabClientAPI.LoginWithCustomID(request, PlayFabUUnitUtils.ApiActionWrapper <LoginResult>(testContext, TestInstCallbacks_GeneralOnlyCallback), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext); CheckCallbacks(testContext, "OnRequest_InstGl", Callbacks); CheckCallbacks(testContext, "OnRequest_InstLogin", Callbacks); testContext.IntEquals(2, Callbacks.Count, string.Join(", ", Callbacks.ToArray())); Callbacks.Clear(); }
public void TestStaticCallbacks_Local(UUnitTestContext testContext) { EventStaticListener.Register(); PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest { CreateAccount = true, CustomId = "UnitySdk-UnitTest", TitleId = "6195" }, PlayFabUUnitUtils.ApiCallbackWrapper<LoginResult>(testContext, TestStaticCallbacks_LocalCallback), SharedErrorCallback, testContext); CheckCallbacks(testContext, "OnRequest_StaticGl", callbacks); CheckCallbacks(testContext, "OnRequest_StaticLogin", callbacks); testContext.IntEquals(2, callbacks.Count, string.Join(", ", callbacks.ToArray())); callbacks.Clear(); }
public void TestInstCallbacks_GeneralOnly(UUnitTestContext testContext) { _listener.Register(); PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest { CreateAccount = true, CustomId = "UnitySdk-UnitTest", TitleId = "6195" }, PlayFabUUnitUtils.ApiCallbackWrapper<LoginResult>(testContext, TestInstCallbacks_GeneralOnlyCallback), null, testContext); testContext.True(callbacks.Contains("OnRequest_InstGl"), string.Join(", ", callbacks.ToArray())); testContext.True(callbacks.Contains("OnRequest_InstLogin"), string.Join(", ", callbacks.ToArray())); testContext.IntEquals(2, callbacks.Count, string.Join(", ", callbacks.ToArray())); callbacks.Clear(); }