Ejemplo n.º 1
0
        public void Remove_OddElementTest()
        {
            BaseArrayWorkerModel x = new BaseArrayWorkerModel();

            ObservableCollection <int> _values      = new ObservableCollection <int>();
            ObservableCollection <int> _even_values = new ObservableCollection <int>();
            ObservableCollection <int> _odd_values  = new ObservableCollection <int>();

            ReadOnlyObservableCollection <int> Values      = new ReadOnlyObservableCollection <int>(_values);
            ReadOnlyObservableCollection <int> Even_Values = new ReadOnlyObservableCollection <int>(_even_values);
            ReadOnlyObservableCollection <int> Odd_Values  = new ReadOnlyObservableCollection <int>(_odd_values);

            x.AddValue(0);
            x.AddValue(1);
            x.AddValue(2);
            x.AddValue(3);
            x.RemoveValue(1);

            _values.Add(0);
            _values.Add(2);
            _values.Add(3);

            _even_values.Add(0);
            _odd_values.Add(2);
            _even_values.Add(3);

            CollectionAssert.AreEqual(x.Values, Values);
            CollectionAssert.AreEqual(x.Even_Values, Even_Values);
            CollectionAssert.AreEqual(x.Odd_Values, Odd_Values);
        }
Ejemplo n.º 2
0
        public ArrayWorkerVM()
        {
            AddCommand = new DelegateCommand(i => {
                _model.AddValue((int?)i);
                MVValues     = _model.Values;
                MVEvenValues = _model.Even_Values;
                MVOddValues  = _model.Odd_Values;
            });

            RemoveCommand = new DelegateCommand(i => {
                if (((int?)i).HasValue)
                {
                    _model.RemoveValue(((int?)i).Value);
                }
                MVValues     = _model.Values;
                MVEvenValues = _model.Even_Values;
                MVOddValues  = _model.Odd_Values;
            });

            RandomGenerateCommand = new DelegateCommand(count => {
                _random_model.RandomGenerate((int)count);
                MVValues     = _random_model.Values;
                MVEvenValues = _random_model.Even_Values;
                MVOddValues  = _random_model.Odd_Values;
            });
        }
Ejemplo n.º 3
0
        public BaseArrayWorkerVM()
        {
            AddCommand = new DelegateCommand(i =>
            {
                _model.AddValue((int?)i);
            });

            RemoveCommand = new DelegateCommand(i =>
            {
                if (((int?)i).HasValue)
                {
                    _model.RemoveValue(((int?)i).Value);
                }
            });

            RandomGenerateCommand = new DelegateCommand(count =>
            {
                _model.RandomGenerate((int)count);
            });
        }