예제 #1
0
        public void Binding_ProtectedGetter(IKeyValueStore store)
        {
            var values = SetupBinder <TestBind>(store);
            var key    = ObjectStoreBinder.GetBindingKey(typeof(TestBind), nameof(TestBind.ProtectedGetterProperty));

            values.BoundObject.ProtectedGetterProperty = Guid.NewGuid().ToString();
            store.Contains(key).Should().BeFalse();
        }
예제 #2
0
        public void NullifyingRemoves(IKeyValueStore store)
        {
            var values = this.SetupBinder <TestBind>(store);
            var key    = ObjectStoreBinder.GetBindingKey(typeof(TestBind), nameof(TestBind.StringProperty));

            values.BoundObject.StringProperty = Guid.NewGuid().ToString();
            store.Contains(key).Should().BeTrue();

            values.BoundObject.StringProperty = null;
            store.Contains(key).Should().BeFalse();
        }
예제 #3
0
        public void DefaultValueRemoves(IKeyValueStore store)
        {
            var values = this.SetupBinder <TestBind>(store);
            var key    = ObjectStoreBinder.GetBindingKey(typeof(TestBind), nameof(TestBind.IntValue));

            values.BoundObject.IntValue = 99;
            store.Get <int>(key).Should().Be(99);

            values.BoundObject.IntValue = 0;
            store.Contains(key).Should().BeFalse();
        }
예제 #4
0
        public void Binding_Basic(IKeyValueStore store)
        {
            var key    = ObjectStoreBinder.GetBindingKey(typeof(TestBind), nameof(TestBind.StringProperty));
            var random = Guid.NewGuid().ToString();
            var values = SetupBinder <TestBind>(store);

            values.BoundObject.StringProperty = random;

            store.Contains(key).Should().BeTrue();
            store.Get <string>(key).Should().Be(random);
        }
예제 #5
0
        public void AttributeBinding()
        {
            var allStores = Data.Select(x => x.First()).Cast <IKeyValueStore>().ToList();
            var factory   = new KeyValueStoreFactory(allStores);
            var binder    = new ObjectStoreBinder(factory, null);

            var obj    = new AttributeTestBind();
            var random = Guid.NewGuid().ToString();

            binder.Bind(obj);
            obj.TestString = random;

            var key = ObjectStoreBinder.GetBindingKey(typeof(AttributeTestBind), nameof(AttributeTestBind.TestString));

            factory
            .GetStore("file")
            .Get <string>(key)
            .Should()
            .Be(random);
        }