public void InsertAtRemoveAt() { IMultiDimensionalArray array = new MultiDimensionalArray(); array.Resize(2, 2); array[0, 0] = 5; array[1, 1] = 2; array.InsertAt(0, 2); log.Info(array.ToString()); array.RemoveAt(0, 2); log.Info(array.ToString()); array.InsertAt(0, 2); log.Info(array.ToString()); array.RemoveAt(0, 2); log.Info(array.ToString()); }
public void RemoveAt() { // Strip an array of 2 column and 2 rows // 1 9 9 2 1 2 // 9 9 9 9 ==> 3 4 // 3 9 9 4 5 6 // 5 9 9 6 // setup this array IMultiDimensionalArray array = new MultiDimensionalArray(4, 4); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { array[i, j] = 9; } } array[0, 0] = 1; array[0, 3] = 2; array[2, 0] = 3; array[2, 3] = 4; array[3, 0] = 5; array[3, 3] = 6; //remove array.RemoveAt(0, 1); //remove one row array.RemoveAt(1, 1, 2); //remove two columns //test results Assert.AreEqual(6, array.Count); Assert.AreEqual(1, array[0, 0]); Assert.AreEqual(2, array[0, 1]); Assert.AreEqual(3, array[1, 0]); Assert.AreEqual(4, array[1, 1]); Assert.AreEqual(5, array[2, 0]); Assert.AreEqual(6, array[2, 1]); }
public void RemoveAt_1D() { //{ 1, 3, 4} --> {1,4} IMultiDimensionalArray array = new MultiDimensionalArray(3); array[0] = 1; array[1] = 3; array[2] = 4; array.RemoveAt(1); Assert.AreEqual(2, array.Count); Assert.AreEqual(1, array[0]); Assert.AreEqual(4, array[1]); }
public void InsertAndRemoveOneDimensionalArray() { //{ 1, 3, 4} --> {1, 2, 3, 4} IMultiDimensionalArray array = new MultiDimensionalArray(3); array[0] = 1; array[1] = 3; array[2] = 4; //insert our new item array.InsertAt(0, 1); array[1] = 2; //TODO : find a nicer way for these asserts. Assert.AreEqual(1, array[0]); Assert.AreEqual(2, array[1]); Assert.AreEqual(3, array[2]); Assert.AreEqual(4, array[3]); // {1,2,3,4} --> {1,4} array.RemoveAt(0, 1, 2); Assert.AreEqual(1, array[0]); Assert.AreEqual(4, array[1]); Assert.AreEqual(2, array.Count); }
public void RemoveAt_1D() { //{ 1, 3, 4} --> {1,4} IMultiDimensionalArray array = new MultiDimensionalArray(3); array[0] = 1; array[1] = 3; array[2] = 4; array.RemoveAt(1); Assert.AreEqual(2, array.Count); Assert.AreEqual(1, array[0]); Assert.AreEqual(4, array[1]); }
public void RemoveAt() { // Strip an array of 2 column and 2 rows // 1 9 9 2 1 2 // 9 9 9 9 ==> 3 4 // 3 9 9 4 5 6 // 5 9 9 6 // setup this array IMultiDimensionalArray array = new MultiDimensionalArray(4, 4); for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) array[i, j] = 9; array[0, 0] = 1; array[0, 3] = 2; array[2, 0] = 3; array[2, 3] = 4; array[3, 0] = 5; array[3, 3] = 6; //remove array.RemoveAt(0, 1); //remove one row array.RemoveAt(1, 1, 2); //remove two columns //test results Assert.AreEqual(6, array.Count); Assert.AreEqual(1, array[0, 0]); Assert.AreEqual(2, array[0, 1]); Assert.AreEqual(3, array[1, 0]); Assert.AreEqual(4, array[1, 1]); Assert.AreEqual(5, array[2, 0]); Assert.AreEqual(6, array[2, 1]); }
public void InsertAtRemoveAt() { IMultiDimensionalArray array = new MultiDimensionalArray(); array.Resize(2, 2); array[0, 0] = 5; array[1, 1] = 2; array.InsertAt(0, 2); log.Info(array.ToString()); array.RemoveAt(0, 2); log.Info(array.ToString()); array.InsertAt(0, 2); log.Info(array.ToString()); array.RemoveAt(0, 2); log.Info(array.ToString()); }
public void InsertAndRemoveOneDimensionalArray() { //{ 1, 3, 4} --> {1, 2, 3, 4} IMultiDimensionalArray array = new MultiDimensionalArray(3); array[0] = 1; array[1] = 3; array[2] = 4; //insert our new item array.InsertAt(0, 1); array[1] = 2; //TODO : find a nicer way for these asserts. Assert.AreEqual(1, array[0]); Assert.AreEqual(2, array[1]); Assert.AreEqual(3, array[2]); Assert.AreEqual(4, array[3]); // {1,2,3,4} --> {1,4} array.RemoveAt(0, 1, 2); Assert.AreEqual(1, array[0]); Assert.AreEqual(4, array[1]); Assert.AreEqual(2, array.Count); }
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 EmptyFirstDimensionDoesNotAlterSecondDimension() { var array = new MultiDimensionalArray<double>(new[] {1, 1}); array.RemoveAt(0,0); Assert.AreEqual(new[]{0,1},array.Shape); }
public void ReadOnlyRemoveAt() { int exCount = 0; var array = new MultiDimensionalArray(true, false, 1,new[]{1}, new[]{1}); IList<Action> calls = new List<Action> { () => array.RemoveAt(0, 0, 1), () => array.RemoveAt(0, 0), () => array.RemoveAt(0) }; calls.ForEach((a) => { try { a(); } catch (Exception ex) { Assert.IsTrue(ex is InvalidOperationException); Assert.AreEqual("Illegal attempt to modify readonly array", ex.Message); exCount++; } }); Assert.AreEqual(3,exCount); }