public void StoreMany() { var collection = new JsonDataCollection <int, TestDataStruct>(TempFilePath); collection.Add( s => s.Id, new List <TestDataStruct> { new TestDataStruct { Id = 1, B = true, C = "Test1" }, new TestDataStruct { Id = 2, B = false, C = "Test2" } } ); collection.Commit(); collection.Clear(); Assert.Empty(collection.All); collection.Refresh(); Assert.Equal("Test1", collection[1].C); Assert.Equal("Test2", collection[2].C); }
void OnEnable() { if (FilePath != null && FilePath != "") { Data = new JsonDataCollection <TKey, TValue>($"Assets/Data/{FilePath}"); } }
public void StoreOne() { var collection = new JsonDataCollection <int, TestDataStruct>(TempFilePath); var obj = new TestDataStruct { Id = 1, B = true, C = "Test" }; collection[obj.Id] = obj; collection.Commit(); collection.Clear(); Assert.Empty(collection.All); collection.Refresh(); Assert.Single(collection.All); var obj2 = collection[obj.Id]; Assert.Equal(obj.B, obj2.B); Assert.Equal(obj.C, obj2.C); }
public void Reset() { Data = new JsonDataCollection <TKey, TValue>($"Assets/Data/{FilePath}"); }