From f5615bbef32a9fa4f53a099a6d357572fb804929 Mon Sep 17 00:00:00 2001 From: Dries Van Schuylenbergh Date: Sat, 8 Apr 2023 11:31:24 +0200 Subject: [PATCH] Fix bug --- .../Scripts/PersistentDataController.cs | 2 +- .../Tests/PersistentDataControllerTest.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Assets/SystemArchitecture/Scripts/PersistentDataController.cs b/Assets/SystemArchitecture/Scripts/PersistentDataController.cs index 6cdf579..2ebf6b0 100644 --- a/Assets/SystemArchitecture/Scripts/PersistentDataController.cs +++ b/Assets/SystemArchitecture/Scripts/PersistentDataController.cs @@ -277,7 +277,7 @@ public class PersistentDataController { string text = File.ReadAllText(PATH); SavedDataStructure newJson = JsonUtility.FromJson(text); - if (newJson == null || newJson.version < VERSION) + if (newJson == null || newJson.version != VERSION) goto failed; json = newJson; diff --git a/Assets/SystemArchitecture/Tests/PersistentDataControllerTest.cs b/Assets/SystemArchitecture/Tests/PersistentDataControllerTest.cs index 68e7fa6..abb291e 100644 --- a/Assets/SystemArchitecture/Tests/PersistentDataControllerTest.cs +++ b/Assets/SystemArchitecture/Tests/PersistentDataControllerTest.cs @@ -107,6 +107,14 @@ public class PersistentDataTests Assert.IsFalse(pdc.Load(false)); } + [Test] + public void Test_PersistentDataController_Load_NewerVersion() + { + string content = $"{{\"version\":{PersistentDataController.VERSION + 1},\"users\":[],\"currentUser\":-1,\"currentMinigame\":0,\"currentCourse\":0,\"currentTheme\":0}}"; + File.WriteAllText(PATH, content); + Assert.IsFalse(pdc.Load(false)); + } + [Test] public void Test_PersistentDataController_Load_New() {