Esempio n. 1
0
        public void BehaviorsAddedToAttachedCollectionAreAttached()
        {
            var behavior   = new MockBehavior <MockBindable> ();
            var collection = new AttachedCollection <Behavior> ();
            var bindable   = new MockBindable();

            ((IAttachedObject)collection).AttachTo(bindable);
            Assert.Null(behavior.AssociatedObject);

            collection.Add(behavior);
            Assert.AreSame(bindable, behavior.AssociatedObject);

            collection.Remove(behavior);
            Assert.Null(behavior.AssociatedObject);
        }
Esempio n. 2
0
        public void AttachTo()
        {
            tlog.Debug(tag, $"AttachTo START");
            IEnumerable <MyView> collection = new List <MyView>()
            {
                new MyView()
            };
            var testingTarget = new AttachedCollection <MyView>(collection);

            Assert.IsNotNull(testingTarget, "Can't create success object AttachedCollection.");

            Assert.Throws <ArgumentNullException>(() => testingTarget.AttachTo(null));


            tlog.Debug(tag, $"AttachTo END");
        }
Esempio n. 3
0
        public void AttachedCollectionConstructor()
        {
            tlog.Debug(tag, $"AttachedCollectionConstructor START");
            IEnumerable <MyView> collection = new List <MyView>()
            {
                new MyView()
            };
            var testingTarget = new AttachedCollection <MyView>(collection);

            Assert.IsNotNull(testingTarget, "Can't create success object AttachedCollection.");

            IList <MyView> list = new List <MyView>()
            {
                new MyView()
            };
            var testingTarget2 = new AttachedCollection <MyView>(list);

            Assert.IsNotNull(testingTarget2, "Can't create success object AttachedCollection.");

            tlog.Debug(tag, $"AttachedCollectionConstructor END");
        }
Esempio n. 4
0
        public void DetachFrom()
        {
            tlog.Debug(tag, $"DetachFrom START");
            try
            {
                IEnumerable <MyView> collection = new List <MyView>()
                {
                    new MyView()
                };
                var testingTarget = new AttachedCollection <MyView>(collection);
                Assert.IsNotNull(testingTarget, "Can't create success object AttachedCollection.");

                var v = new MyView();
                testingTarget.AttachTo(v);
                testingTarget.DetachFrom(v);
            }
            catch (Exception e)
            {
                Assert.Fail("Catch exception: " + e.Message.ToString());
            }

            tlog.Debug(tag, $"DetachFrom END");
        }