コード例 #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);
        }