public void RowInsertionOneBeforeEnd() { DoubleColumn d = new DoubleColumn(10); Assert.AreEqual(0, d.Count); Assert.AreEqual(false, d.IsDirty); // set rows 0 to 9 to i for (int i = 0; i < 10; i++) { d[i] = i; } Assert.AreEqual(10, d.Count); // testing parent change notification setting the parent MyColumnParent parent = new MyColumnParent(); parent.ChildChanged = new EventHandler(parent.TestParentAddNotification); d.ParentObject = parent; Assert.AreEqual(1, parent.CallCount, "There was no parent add notification"); parent.Reset(); parent.Reset(); parent.ChildChanged = new EventHandler(parent.ExpectingDataChange9To12_NoDecrease); // now insert d.InsertRows(9, 3); Assert.AreEqual(1, parent.CallCount, "There was no data change notification"); // test the data Assert.AreEqual(13, d.Count); for (int i = 0; i < 9; i++) { Assert.AreEqual(i, d[i]); } Assert.AreEqual(double.NaN, d[9]); Assert.AreEqual(double.NaN, d[10]); Assert.AreEqual(double.NaN, d[11]); for (int i = 12; i < 13; i++) { Assert.AreEqual(i - 3, d[i]); } }
public void RowInsertionInTheMiddle() { var d = new DoubleColumn(10); Assert.AreEqual(0, d.Count); Assert.AreEqual(false, d.IsDirty); // set rows 0 to 9 to i for (int i = 0; i < 10; i++) { d[i] = i; } Assert.AreEqual(10, d.Count); // testing parent change notification setting the parent var parent = new MyColumnParent(); parent.ChildChanged = new EventHandler(parent.TestParentAddNotification); d.ParentObject = parent; Assert.AreEqual(1, parent.CallCount, "There was no parent add notification"); parent.Reset(); parent.Reset(); parent.ChildChanged = new EventHandler(parent.ExpectingDataChange5To12_NoDecrease); // now insert d.InsertRows(5, 3); Assert.AreEqual(1, parent.CallCount, "There was no data change notification"); // test the data Assert.AreEqual(13, d.Count); for (int i = 0; i < 5; i++) { Assert.AreEqual(i, d[i]); } Assert.AreEqual(double.NaN, d[5]); Assert.AreEqual(double.NaN, d[6]); Assert.AreEqual(double.NaN, d[7]); for (int i = 8; i < (8 + 5); i++) { Assert.AreEqual(i - 3, d[i]); } }
public void ParentNotification() { DoubleColumn d = new DoubleColumn(10); Assert.AreEqual(0, d.Count); Assert.AreEqual(false, d.IsDirty); // testing parent change notification MyColumnParent parent = new MyColumnParent(); parent.ChildChanged = new EventHandler(parent.TestParentAddNotification); d.ParentObject = parent; Assert.AreEqual(1, parent.CallCount, "There was no parent add notification"); parent.Reset(); // testing parent change notification resetting parent parent.ChildChanged = new EventHandler(parent.TestParentRemoveNotification); d.ParentObject = null; Assert.AreEqual(1, parent.CallCount, "There was no parent remove notification"); parent.Reset(); }
public void RowInsertionAtTheEnd() { DoubleColumn d = new DoubleColumn(10); Assert.AreEqual(0, d.Count); Assert.AreEqual(false, d.IsDirty); // set rows 0 to 9 to i for (int i = 0; i < 10; i++) { d[i] = i; } Assert.AreEqual(10, d.Count); // testing parent change notification setting the parent MyColumnParent parent = new MyColumnParent(); parent.ChildChanged = new EventHandler(parent.TestParentAddNotification); d.ParentObject = parent; Assert.AreEqual(1, parent.CallCount, "There was no parent add notification"); parent.Reset(); parent.Reset(); parent.ChildChanged = new EventHandler(parent.ExpectingNotToBeCalledBecauseNoChange); // now insert d.InsertRows(10, 3); // test the data Assert.AreEqual(10, d.Count); for (int i = 0; i < 10; i++) { Assert.AreEqual(i, d[i]); } Assert.AreEqual(double.NaN, d[10]); }
public void DataChangeNotification() { DoubleColumn d = new DoubleColumn(10); Assert.AreEqual(0, d.Count); Assert.AreEqual(false, d.IsDirty); // testing parent change notification MyColumnParent parent = new MyColumnParent(); parent.ChildChanged = new EventHandler(parent.TestParentAddNotification); d.ParentObject = parent; Assert.AreEqual(1, parent.CallCount, "There was no parent add notification"); parent.Reset(); // test data change notification setting row5 parent.ChildChanged = new EventHandler(parent.TestSetSlot5); d.Changed += new EventHandler(parent.TestSetSlot5); d[5] = 66; Assert.AreEqual(2, parent.CallCount, "There was no data change notification setting d[5]"); d.Changed -= new EventHandler(parent.TestSetSlot5); parent.Reset(); // testing data change notification resetting row5 -> count drops to zero parent.ChildChanged = new EventHandler(parent.TestResetSlot5); d[5] = double.NaN; Assert.AreEqual(1, parent.CallCount, "There was no data change notification setting d[5]"); parent.Reset(); // Test d[7] setting to NaN -> the column must not rise a change event parent.ChildChanged = new EventHandler(parent.TestSetSlot7AndSuspend); d[7] = double.NaN; Assert.AreEqual(0, parent.CallCount, "There is no data change notification expected setting d[7] to invalid"); Assert.AreEqual(false, d.IsDirty); parent.Reset(); // Set slot7 returning true -> the column must suspend parent.ChildChanged = new EventHandler(parent.TestSetSlot7AndSuspend); d.Changed += new EventHandler(parent.TestSetSlot7AndSuspend); d[7] = 88; Assert.AreEqual(1, parent.CallCount, "There was no data change notification setting d[7]"); Assert.AreEqual(true, d.IsDirty); d.Changed -= new EventHandler(parent.TestSetSlot7AndSuspend); parent.Reset(); // now the column must not be call the OnChildChange function, // but accumulate the changed parent.ChildChanged = new EventHandler(parent.ExpectingNotToBeCalledBecauseSuspended); d.Changed += new EventHandler(parent.ExpectingNotToBeCalledBecauseSuspended); d[0] = 3; d[7] = double.NaN; // to force the row count has decreased d[12] = 22; d[14] = double.NaN; d.Changed -= new EventHandler(parent.ExpectingNotToBeCalledBecauseSuspended); // the accumulated state should now be row 0 - 12, and the row count decreased parent.Reset(); parent.ChildChanged = new EventHandler(parent.CheckChange0To12_Decreased); d.Changed += new EventHandler(parent.CheckChange0To12_Decreased); d.Resume(); Assert.AreEqual(2, parent.CallCount, "There was no data change notification setting d[0] to d[12]"); Assert.AreEqual(false, d.IsDirty); d.Changed -= new EventHandler(parent.CheckChange0To12_Decreased); parent.Reset(); }
public void RowInsertionAtTheEnd() { DoubleColumn d = new DoubleColumn(10); Assert.AreEqual(0, d.Count); Assert.AreEqual(false, d.IsDirty); // set rows 0 to 9 to i for (int i = 0; i < 10; i++) d[i] = i; Assert.AreEqual(10, d.Count); // testing parent change notification setting the parent MyColumnParent parent = new MyColumnParent(); parent.ChildChanged = new EventHandler(parent.TestParentAddNotification); d.ParentObject = parent; Assert.AreEqual(1, parent.CallCount, "There was no parent add notification"); parent.Reset(); parent.Reset(); parent.ChildChanged = new EventHandler(parent.ExpectingNotToBeCalledBecauseNoChange); // now insert d.InsertRows(10, 3); // test the data Assert.AreEqual(10, d.Count); for (int i = 0; i < 10; i++) Assert.AreEqual(i, d[i]); Assert.AreEqual(double.NaN, d[10]); }
public void RowInsertionOneBeforeEnd() { DoubleColumn d = new DoubleColumn(10); Assert.AreEqual(0, d.Count); Assert.AreEqual(false, d.IsDirty); // set rows 0 to 9 to i for (int i = 0; i < 10; i++) d[i] = i; Assert.AreEqual(10, d.Count); // testing parent change notification setting the parent MyColumnParent parent = new MyColumnParent(); parent.ChildChanged = new EventHandler(parent.TestParentAddNotification); d.ParentObject = parent; Assert.AreEqual(1, parent.CallCount, "There was no parent add notification"); parent.Reset(); parent.Reset(); parent.ChildChanged = new EventHandler(parent.ExpectingDataChange9To12_NoDecrease); // now insert d.InsertRows(9, 3); Assert.AreEqual(1, parent.CallCount, "There was no data change notification"); // test the data Assert.AreEqual(13, d.Count); for (int i = 0; i < 9; i++) Assert.AreEqual(i, d[i]); Assert.AreEqual(double.NaN, d[9]); Assert.AreEqual(double.NaN, d[10]); Assert.AreEqual(double.NaN, d[11]); for (int i = 12; i < 13; i++) Assert.AreEqual(i - 3, d[i]); }
public void DataChangeNotification() { DoubleColumn d = new DoubleColumn(10); Assert.AreEqual(0, d.Count); Assert.AreEqual(false, d.IsDirty); // testing parent change notification MyColumnParent parent = new MyColumnParent(); parent.ChildChanged = new EventHandler(parent.TestParentAddNotification); d.ParentObject = parent; Assert.AreEqual(1, parent.CallCount, "There was no parent add notification"); parent.Reset(); // test data change notification setting row5 parent.ChildChanged = new EventHandler(parent.TestSetSlot5); d.Changed += new EventHandler(parent.TestSetSlot5); d[5] = 66; Assert.AreEqual(2, parent.CallCount, "There was no data change notification setting d[5]"); d.Changed -= new EventHandler(parent.TestSetSlot5); parent.Reset(); // testing data change notification resetting row5 -> count drops to zero parent.ChildChanged = new EventHandler(parent.TestResetSlot5); d[5] = double.NaN; Assert.AreEqual(1, parent.CallCount, "There was no data change notification setting d[5]"); parent.Reset(); // Test d[7] setting to NaN -> the column must not rise a change event parent.ChildChanged = new EventHandler(parent.TestSetSlot7AndSuspend); d[7] = double.NaN; Assert.AreEqual(0, parent.CallCount, "There is no data change notification expected setting d[7] to invalid"); Assert.AreEqual(false, d.IsDirty); parent.Reset(); // Set slot7 returning true -> the column must suspend parent.ChildChanged = new EventHandler(parent.TestSetSlot7AndSuspend); d.Changed += new EventHandler(parent.TestSetSlot7AndSuspend); d[7] = 88; Assert.AreEqual(1, parent.CallCount, "There was no data change notification setting d[7]"); Assert.AreEqual(true, d.IsDirty); d.Changed -= new EventHandler(parent.TestSetSlot7AndSuspend); parent.Reset(); // now the column must not be call the OnChildChange function, // but accumulate the changed parent.ChildChanged = new EventHandler(parent.ExpectingNotToBeCalledBecauseSuspended); d.Changed += new EventHandler(parent.ExpectingNotToBeCalledBecauseSuspended); d[0] = 3; d[7] = double.NaN; // to force the row count has decreased d[12] = 22; d[14] = double.NaN; d.Changed -= new EventHandler(parent.ExpectingNotToBeCalledBecauseSuspended); // the accumulated state should now be row 0 - 12, and the row count decreased parent.Reset(); parent.ChildChanged = new EventHandler(parent.CheckChange0To12_Decreased); d.Changed += new EventHandler(parent.CheckChange0To12_Decreased); parent.Resume(); Assert.AreEqual(2, parent.CallCount, "There was no data change notification setting d[0] to d[12]"); Assert.AreEqual(false, d.IsDirty); d.Changed -= new EventHandler(parent.CheckChange0To12_Decreased); parent.Reset(); }