public async void BasicDeserialization_002() { String targetPath = await Storage.Instance.GetFolderPath(Storage.Instance.folder) + "\\"; String sourceFolder = TestHelper.testDataLocation + "\\SampleDataFiles\\Test_002\\"; File.Copy(sourceFolder + "sessions.xml", targetPath + "sessions.xml", true); File.Copy(sourceFolder + "userdetails.xml", targetPath + "userdetails.xml", true); File.Copy(sourceFolder + "events.xml", targetPath + "events.xml", true); File.Copy(sourceFolder + "exceptions.xml", targetPath + "exceptions.xml", true); File.Copy(sourceFolder + "device.xml", targetPath + "device.xml", true); File.Copy(sourceFolder + "storedRequests.xml", targetPath + "storedRequests.xml", true); Countly.Instance.deferUpload = true; CountlyConfig cc = TestHelper.CreateConfig(); await Countly.Instance.Init(cc); Assert.Equal(100, Countly.Instance.Events.Count); Assert.Equal(100, Countly.Instance.Exceptions.Count); Assert.Equal(102, Countly.Instance.Sessions.Count); Assert.Equal(150, Countly.Instance.StoredRequests.Count); Assert.Equal("SDSDSD1570501868", await Countly.GetDeviceId()); CountlyUserDetails cud = Countly.UserDetails; Assert.Equal(975, cud.BirthYear); Assert.Equal("g", cud.Email); Assert.Equal("1t", cud.Gender); Assert.Equal("12g", cud.Name); Assert.Equal("12s", cud.Organization); Assert.Equal("1p", cud.Phone); Assert.Equal("12t", cud.Picture); Assert.Equal("1u", cud.Username); }
public async void BasicDeserialization_18_1() { String targetPath = await Storage.Instance.GetFolderPath(Storage.Instance.folder) + "\\"; String sourceFolder = TestHelper.testDataLocation + "\\SampleDataFiles\\18_1\\"; File.Copy(sourceFolder + "sessions.xml", targetPath + "sessions.xml"); File.Copy(sourceFolder + "userdetails.xml", targetPath + "userdetails.xml"); File.Copy(sourceFolder + "events.xml", targetPath + "events.xml"); File.Copy(sourceFolder + "exceptions.xml", targetPath + "exceptions.xml"); File.Copy(sourceFolder + "devicePCL.xml", targetPath + "device.xml"); Countly.Instance.deferUpload = true; await CountlyImpl.StartLegacyCountlySession(ServerInfo.serverURL, ServerInfo.appKey, ServerInfo.appVersion); Assert.Equal(50, Countly.Instance.Events.Count); Assert.Equal(50, Countly.Instance.Exceptions.Count); Assert.Equal(3, Countly.Instance.Sessions.Count); Assert.Empty(Countly.Instance.StoredRequests); Assert.Equal("B249FB85668941FAA8301E2A5CA95901", await Countly.GetDeviceId()); CountlyUserDetails cud = Countly.UserDetails; Assert.Equal(56, cud.BirthYear); Assert.Equal("f", cud.Email); Assert.Equal("t", cud.Gender); Assert.Equal("g", cud.Name); Assert.Equal("s", cud.Organization); Assert.Equal("p", cud.Phone); Assert.Equal("1t", cud.Picture); Assert.Equal("u", cud.Username); }
public async void DeserializeDeviceIdString_18_1() { String targetPath = await Storage.Instance.GetFolderPath(Storage.Instance.folder) + "\\"; String sourceFolder = TestHelper.testDataLocation + "\\SampleDataFiles\\18_1\\"; File.Copy(sourceFolder + "devicePCL.xml", targetPath + "device.xml"); CountlyConfig cc = TestHelper.CreateConfig(); await Countly.Instance.Init(cc); String deviceId = "B249FB85668941FAA8301E2A5CA95901"; Assert.Equal(deviceId, await Countly.GetDeviceId()); DeviceId res = await Storage.Instance.LoadFromFile <DeviceId>(Device.deviceFilename); Assert.Equal(deviceId, res.deviceId); Assert.True((DeviceBase.DeviceIdMethodInternal)Countly.DeviceIdMethod.windowsGUID == res.deviceIdMethod); }
public async Task Run() { Console.WriteLine("Hello to the Countly sample console program"); if (serverURL == null || appKey == null) { Console.WriteLine(""); Console.WriteLine("Problem encountered, you have not set up either the serverURL or the appKey"); Console.ReadKey(); return; } Countly.IsLoggingEnabled = true; //Countly.SetCustomDataPath(@"D:\123z\");//usable only when targeting .net3.5 //Countly.SetCustomDataPath(null); //Countly.deferUpload = true;//this call is only available by allowing access to internal members to this project, should not be used await Countly.StartSession(serverURL, appKey, "1.234", Countly.DeviceIdMethod.multipleFields); Console.WriteLine("DeviceID: " + await Countly.GetDeviceId()); System.Console.WriteLine("DeviceID: " + await Countly.GetDeviceId()); while (true) { Console.WriteLine(""); Console.WriteLine("Choose your option:"); Console.WriteLine("1) Sample event"); Console.WriteLine("2) Sample caught exception"); Console.WriteLine("3) Change deviceID to a random value (create new user)"); Console.WriteLine("4) Change the name of the current user"); Console.WriteLine("5) Exit"); Console.WriteLine("6) Another caught Exception"); Console.WriteLine("7) Test"); if (enableDebugOpptions) { Console.WriteLine("8) (debug) Threading test"); } ConsoleKeyInfo cki = System.Console.ReadKey(); Console.WriteLine(""); if (cki.Key == ConsoleKey.D1) { System.Console.WriteLine("1"); Countly.RecordEvent("Some event"); } else if (cki.Key == ConsoleKey.D2) { Console.WriteLine("2"); try { throw new Exception("This is some bad exception 3"); } catch (Exception ex) { Dictionary <string, string> customInfo = new Dictionary <string, string>(); customInfo.Add("customData", "importantStuff"); Countly.RecordException(ex.Message, ex.StackTrace, customInfo); } } else if (cki.Key == ConsoleKey.D3) { Console.WriteLine("3"); //await Device.SetDeviceId("ID-" + (new Random()).Next()); } else if (cki.Key == ConsoleKey.D4) { Console.WriteLine("4"); Countly.UserDetails.Name = "Some Username " + (new Random()).Next(); } else if (cki.Key == ConsoleKey.D5) { Console.WriteLine("5"); break; } else if (cki.Key == ConsoleKey.D6) { Console.WriteLine("6"); Countly.RecordException("What is here", ""); } else if (cki.Key == ConsoleKey.D7) { Console.WriteLine("7"); } else if (enableDebugOpptions && cki.Key == ConsoleKey.D8) { Console.WriteLine("8"); Console.WriteLine("Running threaded debug test"); ThreadTest(); } else { Console.WriteLine("Wrong input, please try again."); } } ; await Countly.EndSession(); }
public async Task Run() { Console.WriteLine("Hello to the Countly sample console program"); Console.WriteLine("DeviceID: " + await Countly.GetDeviceId()); if (serverURL == null || appKey == null) { Console.WriteLine(""); Console.WriteLine("Problem encountered, you have not set up either the serverURL or the appKey"); Console.ReadKey(); return; } Countly.IsLoggingEnabled = true; //Countly.deferUpload = true; await Countly.StartSession(serverURL, appKey, "1.234", FileSystem.Current); System.Console.WriteLine("DeviceID: " + await Countly.GetDeviceId()); while (true) { Console.WriteLine(""); Console.WriteLine("Choose your option:"); Console.WriteLine("1) Sample event"); Console.WriteLine("2) Sample caught exception"); Console.WriteLine("3) Change deviceID to a random value (create new user)"); Console.WriteLine("4) Change the name of the current user"); Console.WriteLine("5) Exit"); Console.WriteLine("6) Another caught Exception"); Console.WriteLine("7) Sample event without await"); if (enableDebugOpptions) { Console.WriteLine("8) (debug) Threading test"); } ConsoleKeyInfo cki = System.Console.ReadKey(); Console.WriteLine(""); if (cki.Key == ConsoleKey.D1) { System.Console.WriteLine("1"); await Countly.RecordEvent("Some event"); } else if (cki.Key == ConsoleKey.D2) { Console.WriteLine("2"); try { throw new Exception("This is some bad exception 3"); } catch (Exception ex) { Dictionary <string, string> customInfo = new Dictionary <string, string>(); customInfo.Add("customData", "importantStuff"); await Countly.RecordException(ex.Message, ex.StackTrace, customInfo); } Exception exToUse; try { throw new Exception("This is some bad exception 35454"); } catch (Exception ex) { exToUse = ex; } Dictionary <String, String> dict = new Dictionary <string, string>(); dict.Add("booh", "waah"); await Countly.RecordException("Big error 1"); await Countly.RecordException(exToUse.Message, exToUse.StackTrace); await Countly.RecordException(exToUse.Message, exToUse.StackTrace, dict); await Countly.RecordException(exToUse.Message, exToUse.StackTrace, dict, false); } else if (cki.Key == ConsoleKey.D3) { Console.WriteLine("3"); //await Device.SetDeviceId("ID-" + (new Random()).Next()); } else if (cki.Key == ConsoleKey.D4) { Console.WriteLine("4"); Countly.UserDetails.Name = "Some Username " + (new Random()).Next(); } else if (cki.Key == ConsoleKey.D5) { Console.WriteLine("5"); break; } else if (cki.Key == ConsoleKey.D6) { Console.WriteLine("6"); await Countly.RecordException("What is here", ""); } else if (cki.Key == ConsoleKey.D7) { Console.WriteLine("7"); Countly.RecordEvent("Some event"); } else if (enableDebugOpptions && cki.Key == ConsoleKey.D8) { Console.WriteLine("8"); Console.WriteLine("Running threaded debug test"); ThreadTest(); } else { Console.WriteLine("Wrong input, please try again."); } } ; await Countly.EndSession(); }