Beispiel #1
0
        public void CanUpdatePreference()
        {
            var key   = "TestIntPreference";
            var store = new MemoryPreferenceStore();

            store.Set(key, 15);
            store.Count.ShouldBe(1);
            store.TryGet(key, out int result);
            result.ShouldBe(15);

            store.Set(key, 12);
            store.Count.ShouldBe(1);
            store.TryGet(key, out int updatedResult);
            updatedResult.ShouldBe(12);
        }
Beispiel #2
0
        public void DefaultValueForMissingPreference()
        {
            var key   = "InvalidKey";
            var store = new MemoryPreferenceStore();

            store.Count.ShouldBe(0);

            var found = store.TryGet(key, out bool result);

            found.ShouldBeFalse();
            result.ShouldBeFalse();
        }
Beispiel #3
0
        public void CanGetAPreference()
        {
            var key   = "SimplePreference";
            var store = new MemoryPreferenceStore();

            store.Set(key, 3);
            store.Count.ShouldBe(1);

            var found = store.TryGet(key, out int result);

            result.ShouldBe(3);
        }
Beispiel #4
0
        public void DefaultValueForUnsetPreference()
        {
            var key   = "DefaultKey";
            var store = new MemoryPreferenceStore();

            store.Set <object>(key, null);
            store.Count.ShouldBe(1);

            var found = store.TryGet(key, out int result);

            found.ShouldBeTrue();
            result.ShouldBe(0);
        }