private static void CustomEvent(string eventName, IUnityAnalyticsExport data = null) { Debugs.Log("Analytics/CustomEvent", eventName); if (data != null) { var dict = GetDictionary(); data.Export(ref dict, PrefixResolver.Default); UnityAnalytics.Analytics.CustomEvent(eventName, dict); EventCreator.AnalyticsEvent(eventName, dict); } else { UnityAnalytics.Analytics.CustomEvent(eventName); EventCreator.AnalyticsEvent(eventName, null); } }
public void Shuffle_ShouldShuffle() { var list = new[] { 1, 2, 3, 4 }; var list2 = new[] { 1, 2, 3, 4 }; list.Shuffle(); Debugs.Log(list.ToConcatenatedString()); Debugs.Log(list2.ToConcatenatedString()); var f = false; for (var i = 0; i < list.Length; i++) { if (list[i] != list2[i]) { f = true; } } Assert.AreEqual(true, f); }
public void TestAsync() { var finished = false; var hasError = false; var start = new DateTime().Millisecond; Asyncs.Execute(() => { Thread.Sleep(100); }) .Subscribe(_ => { Debugs.Log("completed"); finished = true; }, e => { Debugs.Exception(e); hasError = true; finished = true; }); Thread.Sleep(300); Assert.AreEqual(true, finished); Assert.AreEqual(false, hasError); }
public void TestFileLogger() { using (var logger = Loggers.NewFileLogger("test", "Temp/test.log", TimeSpan.FromMinutes(1), null, true, FileMode.Create)) { logger.Log("way", "loglog"); var bytes = Files.TryRead("Temp/test.log"); // 書き込まれてない Assert.AreEqual(0, bytes.Length); logger.Flush(true); // 書き込まれてる bytes = Files.TryRead("Temp/test.log"); var line = Encoding.UTF8.GetString(bytes); Assert.AreEqual(true, bytes.Length > 0); Debugs.Log(line); var regex = new Regex( "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+\\d{2}:\\d{2} \\d{3}ms/\\d+?F <L> \\[test/way\\]: loglog$"); Assert.AreEqual(true, regex.Match(line).Success); } }