Ejemplo n.º 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 _));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 5
0
 public void FromValue_should_throw_on_missing_argument()
 {
     Assert.Throws <ArgumentNullException>(
         () => AttachedPropertyStore.FromValue(null)
         );
 }