public void Create1D() { IMultiDimensionalArray array = new MultiDimensionalArray(); array.Add(1); array.Add(2); array.Add(3); array.Remove(2); log.Info(array.ToString()); Assert.AreEqual(1, array.Rank); Assert.AreEqual(2, array.Count); }
public void IndexOnValuesRemoved() { IMultiDimensionalArray <int> array = new MultiDimensionalArray <int>(); array.Add(2); array.Add(3); int callCount = 0; array.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e) { var args = (MultiDimensionalArrayChangedEventArgs)e; Assert.AreEqual(new[] { 1 }, args.MultiDimensionalIndex); callCount++; }; array.Remove(3); Assert.AreEqual(1, callCount); }
public void IndexOnValuesRemoved() { IMultiDimensionalArray<int> array = new MultiDimensionalArray<int>(); array.Add(2); array.Add(3); int callCount = 0; array.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e) { var args = (MultiDimensionalArrayChangedEventArgs)e; Assert.AreEqual(new[] { 1 }, args.MultiDimensionalIndex); callCount++; }; array.Remove(3); Assert.AreEqual(1, callCount); }
public void Create1D() { IMultiDimensionalArray array = new MultiDimensionalArray(); array.Add(1); array.Add(2); array.Add(3); array.Remove(2); log.Info(array.ToString()); Assert.AreEqual(1, array.Rank); Assert.AreEqual(2, array.Count); }
public void IndexOnValuesRemoved() { IMultiDimensionalArray<int> array = new MultiDimensionalArray<int>(); array.Add(2); array.Add(3); int callCount = 0; array.CollectionChanged += (sender, e) => { Assert.AreEqual(new[] {1}, e.MultiDimensionalIndex); callCount++; }; array.Remove(3); Assert.AreEqual(1, callCount); }
public void UnsubscribePropertyChanged() { var testNotifyPropertyChangedObject = new TestNotifyPropertyChangedObject(); IMultiDimensionalArray<TestNotifyPropertyChangedObject> array = new MultiDimensionalArray<TestNotifyPropertyChangedObject>(); //remove the item from the array array.Insert(0, testNotifyPropertyChangedObject); TestHelper.AssertPropertyChangedIsFired((INotifyPropertyChanged)array, 1, testNotifyPropertyChangedObject.FireChanged); array.Remove(testNotifyPropertyChangedObject); TestHelper.AssertPropertyChangedIsFired((INotifyPropertyChanged)array, 0, testNotifyPropertyChangedObject.FireChanged); //reinsert & replace array.Insert(0,testNotifyPropertyChangedObject); array[0] = new TestNotifyPropertyChangedObject {Name = "new"}; TestHelper.AssertPropertyChangedIsFired((INotifyPropertyChanged)array, 0, testNotifyPropertyChangedObject.FireChanged); //removeat array.Insert(0, testNotifyPropertyChangedObject); array.RemoveAt(0); TestHelper.AssertPropertyChangedIsFired((INotifyPropertyChanged)array, 0, testNotifyPropertyChangedObject.FireChanged); }
public void RemoveDoesNothingWhenValueIsNotInArray() { IMultiDimensionalArray<double> array = new MultiDimensionalArray<double>() {IsAutoSorted = true}; array.Add(0.0); array.Add(10.0); //remove something that was never there. shoud have no effect (just like in List<T> array.Remove(11.0d); Assert.AreEqual(new[]{0.0,10.0},array); }
public void PerformanceRemoveValues() { IMultiDimensionalArray<double> array = new MultiDimensionalArray<double>(); const int valuesToRemove = 200000; var values = Enumerable.Range(1, valuesToRemove).Select(Convert.ToDouble).ToArray(); array.AddRange(values); TestHelper.AssertIsFasterThan(95000, () => values.ForEach(d => array.Remove(d))); //too slow }
public void ReadOnlyRemove() { var array = new MultiDimensionalArray(true, false, 1, new int[1]); array.Remove(1); }