コード例 #1
0
        public void SetProperty_should_add_value_to_store()
        {
            object instance = new object();
            var    store    = AttachedPropertyStore.FromValue(instance);

            store.SetProperty(Prop, instance);
            Assert.True(store.TryGetProperty(Prop, out _));
        }
コード例 #2
0
        public void FromValue_should_create_reusable_store()
        {
            object instance = new object();
            var    store1   = AttachedPropertyStore.FromValue(instance);
            var    store2   = AttachedPropertyStore.FromValue(instance);

            Assert.Same(store1, store2);
        }
コード例 #3
0
        public void TryGetProperty_should_retrieve_value()
        {
            object instance = new object();
            var    store    = AttachedPropertyStore.FromValue(instance);

            store.SetProperty(Prop, instance);
            store.TryGetProperty(Prop, out var result);
            Assert.Same(instance, result);
        }
コード例 #4
0
        public void GetEnumerator_should_contain_contents()
        {
            object instance = new object();
            var    store    = AttachedPropertyStore.FromValue(instance);

            store.SetProperty(Prop, instance);
            Assert.Equal(new [] {
                KeyValuePair.Create(Prop, instance),
            }, store.ToArray());
        }
コード例 #5
0
 public void FromValue_should_throw_on_missing_argument()
 {
     Assert.Throws <ArgumentNullException>(
         () => AttachedPropertyStore.FromValue(null)
         );
 }