[Test] public void SettingArrayTest() { for (int i = 0; i < 10; ++i) { IResource setting = Core.ResourceStore.BeginNewResource("Setting"); setting.EndUpdate(); } IResourceList resources = Core.ResourceStore.GetAllResources("Setting"); SettingArray settings = SettingArray.FromResourceList(resources, _SIZE, 100); Assert.AreEqual(false, settings.Defined); Assert.AreEqual(100, settings.Value); Assert.AreEqual(false, settings.Different); for (int i = 0; i < 10; ++i) { IResource setting = Core.ResourceStore.BeginNewResource("Setting"); setting.SetProp(_SIZE, i); setting.EndUpdate(); } resources = Core.ResourceStore.GetAllResources("Setting"); settings = SettingArray.FromResourceList(resources, _SIZE, 100); Assert.AreEqual(false, settings.Defined); Assert.AreEqual(true, settings.Different); settings.Save(333); IResourceList list = Core.ResourceStore.FindResources("Setting", _SIZE, 333); Assert.AreEqual(20, list.Count); resources = Core.ResourceStore.GetAllResources("Setting"); settings = SettingArray.FromResourceList(resources, _SIZE, 100); Assert.AreEqual(true, settings.Defined); Assert.AreEqual(333, settings.Value); Assert.AreEqual(false, settings.Different); }
[Test] public void IntAsBoolSettingArrayTest() { IResource setting = Core.ResourceStore.BeginNewResource("Setting"); setting.EndUpdate(); setting = Core.ResourceStore.BeginNewResource("Setting"); setting.SetProp(_NUM, -1); setting.EndUpdate(); IResourceList resources = Core.ResourceStore.GetAllResources("Setting"); SettingArray settings = SettingArray.IntAsBoolFromResourceList(resources, _NUM, true); Assert.AreEqual(false, settings.Defined); Assert.AreEqual(true, settings.Different); settings.Save(true); resources = Core.ResourceStore.GetAllResources("Setting"); settings = SettingArray.IntAsBoolFromResourceList(resources, _NUM, true); settings.Load(); Assert.AreEqual(true, settings.Defined); Assert.AreEqual(true, settings.Value); Assert.AreEqual(false, settings.Different); }