public void GivenDefaultProviderWithKeyAndValueAbsent_WhenGetValue_ThenDefaultReturned() { DefaultValueProvider provider = Substitute.For <DefaultValueProvider>(); store = new SerialSaveStore(persister, provider); string key0 = "key0"; persister.ReadData().Returns(new Dictionary <string, object>()); store.Load(); string expectedDefault = "someMagicDefault"; provider.GetDefaultValue(key0).Returns(expectedDefault); object actual = store.GetValue(key0); Assert.That(actual, Is.EqualTo(expectedDefault)); }
public void GivenDefaultProviderWithTypedSaveKeyAndValueAbsent_WhenGetValueTyped_ThenDefaultReturned() { DefaultValueProvider provider = Substitute.For <DefaultValueProvider>(); store = new SerialSaveStore(persister, provider); SaveKey <int> key0 = new SaveKey <int>("key0"); persister.ReadData().Returns(new Dictionary <string, object>()); store.Load(); int expectedDefault = 5005; provider.GetDefaultValue(key0.Name).Returns(expectedDefault); int actual = store.GetValue <int>(key0); Assert.That(actual, Is.EqualTo(expectedDefault)); }
void Start() { saveStore = saveDataStore.SaveStore; saveStore.ValueChanged += CounterValueChanged; saveStore.StoreLoaded += StoreLoaded; }
/// <summary> /// Create an accessor to the specified save store for the provided save key. /// </summary> /// <param name="saveKey">The key to read and write the value for.</param> /// <param name="saveStore">The save store to use.</param> public SaveValueAccessor(SaveKey <T> saveKey, SerialSaveStore saveStore) { this.saveKey = saveKey; this.saveStore = saveStore; }
void Awake() { SaveStore = new SerialSaveStore(filename); SaveStore.StoreLoaded += SaveDataLoadedSuccessfully; SaveStore.StoreSaved += SaveDataSavedSuccessfully; }
public void SetUp() { persister = Substitute.For <Persister>(); store = new SerialSaveStore(persister); store.Load(); }
void Start() { saveStore = saveDataStore.SaveStore; }