예제 #1
0
        public void TestSaveAndLoadAppDataFolder()
        {
            const string AppName  = "ZicoreBaseTest";
            const string FileName = "Test.json";

            var filePath = JsonSerializable.GetAppDataFilePath(FileName, AppName);

            // Ensure to delete before test
            File.Delete(filePath);

            JsonSerialzableTestValues test = new JsonSerialzableTestValues();

            try
            {
                // Assign Test Values
                AssignTestValues(test, _testValues);

                // Save to file
                test.SaveToAppData(FileName, AppName);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            test = new JsonSerialzableTestValues(); // Create new class with different values
            try
            {
                test.LoadFromAppData(FileName, AppName);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            // Test against test values
            CompareValues(test, _testValues);

            // cleanup test file
            try
            {
                File.Delete(filePath);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }