Exemplo n.º 1
0
        public void INCCComplexRemoveLast()
        {
            var oc      = new ObservableCollection <View>();
            var wrapper = new ObservableWrapper <View, Button>(oc);

            oc.Add(new Stepper());

            wrapper.Add(new Button());
            wrapper.Add(new Button());
            var child = new Button();

            wrapper.Add(child);

            Button removedResult = null;
            int    removeIndex   = -1;

            wrapper.CollectionChanged += (sender, args) =>
            {
                removedResult = args.OldItems[0] as Button;
                removeIndex   = args.OldStartingIndex;
            };

            wrapper.Remove(child);

            Assert.AreEqual(child, removedResult);
            Assert.AreEqual(2, removeIndex);
        }
Exemplo n.º 2
0
        public void CannotRemoveInternalItem()
        {
            var observableCollection = new ObservableCollection <View>();
            var wrapper = new ObservableWrapper <View, View>(observableCollection);

            var child = new View();

            observableCollection.Add(child);

            Assert.IsEmpty(wrapper);

            Assert.False(wrapper.Remove(child));

            Assert.Contains(child, observableCollection);
        }
Exemplo n.º 3
0
        public void ReadOnly()
        {
            var observableCollection = new ObservableCollection <View>();
            var wrapper = new ObservableWrapper <View, Button>(observableCollection);

            Assert.False(wrapper.IsReadOnly);

            wrapper.Add(new Button());

            wrapper.IsReadOnly = true;

            Assert.True(wrapper.IsReadOnly);

            Assert.Throws <NotSupportedException>(() => wrapper.Remove(wrapper[0]));
            Assert.Throws <NotSupportedException>(() => wrapper.Add(new Button()));
            Assert.Throws <NotSupportedException>(() => wrapper.RemoveAt(0));
            Assert.Throws <NotSupportedException>(() => wrapper.Insert(0, new Button()));
            Assert.Throws <NotSupportedException>(wrapper.Clear);
        }
Exemplo n.º 4
0
		public void INCCComplexRemoveLast ()
		{
			var oc = new ObservableCollection<View> ();
			var wrapper = new ObservableWrapper<View, Button> (oc);

			oc.Add (new Stepper ());

			wrapper.Add (new Button ());
			wrapper.Add (new Button ());
			var child = new Button ();
			wrapper.Add (child);

			Button removedResult = null;
			int removeIndex = -1;
			wrapper.CollectionChanged += (sender, args) => {
				removedResult = args.OldItems[0] as Button;
				removeIndex = args.OldStartingIndex;
			};

			wrapper.Remove (child);

			Assert.AreEqual (child, removedResult);
			Assert.AreEqual (2, removeIndex);
		}
Exemplo n.º 5
0
		public void ReadOnly ()
		{
			var observableCollection = new ObservableCollection<View> ();
			var wrapper = new ObservableWrapper<View, Button> (observableCollection);

			Assert.False (wrapper.IsReadOnly);

			wrapper.Add (new Button ());

			wrapper.IsReadOnly = true;

			Assert.True (wrapper.IsReadOnly);

			Assert.Throws<NotSupportedException> (() => wrapper.Remove (wrapper[0]));
			Assert.Throws<NotSupportedException> (() => wrapper.Add (new Button ()));
			Assert.Throws<NotSupportedException> (() => wrapper.RemoveAt (0));
			Assert.Throws<NotSupportedException> (() => wrapper.Insert (0, new Button ()));
			Assert.Throws<NotSupportedException> (wrapper.Clear);
		}
Exemplo n.º 6
0
		public void CannotRemoveInternalItem ()
		{
			var observableCollection = new ObservableCollection<View> ();
			var wrapper = new ObservableWrapper<View, View> (observableCollection);

			var child = new View ();

			observableCollection.Add (child);

			Assert.IsEmpty (wrapper);

			Assert.False (wrapper.Remove (child));

			Assert.Contains (child, observableCollection);
		}