public void NumericUpDown_BeginInit() { NumericNew nud = new NumericNew(); nud.TextChanged += new EventHandler(NumericUpDown_TextChanged); nud.ValueChanged += new EventHandler(NumericUpDown_ValueChanged); Assert.AreEqual(2, nud.CallStack.Count, "#A1"); Assert.AreEqual("ValidateEditText", nud.CallStack [0], "#A2"); Assert.AreEqual("UpdateEditText", nud.CallStack [1], "#A3"); Assert.AreEqual(0, nud.Value, "#A4"); Assert.AreEqual(2, nud.CallStack.Count, "#A5"); Assert.AreEqual(0, value_changed, "#A6"); Assert.AreEqual(0, text_changed, "#A7"); nud.BeginInit(); Assert.AreEqual(2, nud.CallStack.Count, "#B1"); nud.Value = 10; Assert.AreEqual(3, nud.CallStack.Count, "#B2"); Assert.AreEqual("UpdateEditText", nud.CallStack [2], "#B3"); Assert.AreEqual("0", nud.Text, "#B4"); Assert.AreEqual(10, nud.Value, "#B5"); Assert.AreEqual(3, nud.CallStack.Count, "#B6"); Assert.AreEqual(1, value_changed, "#B7"); Assert.AreEqual(0, text_changed, "#B8"); nud.EndInit(); Assert.AreEqual(4, nud.CallStack.Count, "#B9"); Assert.AreEqual("UpdateEditText", nud.CallStack [3], "#B10"); Assert.AreEqual(1, text_changed, "#B11"); Assert.AreEqual("10", nud.Text, "#B12"); Assert.AreEqual(10, nud.Value, "#B13"); Assert.AreEqual(4, nud.CallStack.Count, "#B14"); Assert.AreEqual(1, value_changed, "#B15"); Assert.AreEqual(1, text_changed, "#B16"); // multiple calls to BeginInit are undone by a single EndInit call nud.BeginInit(); nud.BeginInit(); Assert.AreEqual(4, nud.CallStack.Count, "#C1"); nud.Value = 20; Assert.AreEqual(5, nud.CallStack.Count, "#C2"); Assert.AreEqual("UpdateEditText", nud.CallStack [4], "#C3"); Assert.AreEqual("10", nud.Text, "#C4"); Assert.AreEqual(20, nud.Value, "#C5"); Assert.AreEqual(5, nud.CallStack.Count, "#C6"); Assert.AreEqual(2, value_changed, "#C7"); Assert.AreEqual(1, text_changed, "#C8"); nud.EndInit(); Assert.AreEqual(6, nud.CallStack.Count, "#C9"); Assert.AreEqual("UpdateEditText", nud.CallStack [5], "#C10"); Assert.AreEqual(2, text_changed, "#C11"); Assert.AreEqual("20", nud.Text, "#C12"); Assert.AreEqual(20, nud.Value, "#C13"); Assert.AreEqual(6, nud.CallStack.Count, "#C14"); Assert.AreEqual(2, value_changed, "#C15"); Assert.AreEqual(2, text_changed, "#C16"); }
public void NumericUpDown_Value_Invalid() { NumericNew nud = new NumericNew(); try { nud.Value = 1000; Assert.Fail("#A1"); } catch (ArgumentOutOfRangeException ex) { Assert.AreEqual(typeof(ArgumentOutOfRangeException), ex.GetType(), "#A2"); Assert.IsNotNull(ex.Message, "#A3"); Assert.IsNotNull(ex.ParamName, "#A4"); Assert.AreEqual("Value", ex.ParamName, "#A5"); Assert.IsNull(ex.InnerException, "#A6"); } try { nud.Value = 1000; Assert.Fail("#B1"); } catch (ArgumentOutOfRangeException ex) { Assert.AreEqual(typeof(ArgumentOutOfRangeException), ex.GetType(), "#B2"); Assert.IsNotNull(ex.Message, "#B3"); Assert.IsNotNull(ex.ParamName, "#B4"); Assert.AreEqual("Value", ex.ParamName, "#B5"); Assert.IsNull(ex.InnerException, "#B6"); } try { nud.Value = -1000; Assert.Fail("#C1"); } catch (ArgumentOutOfRangeException ex) { Assert.AreEqual(typeof(ArgumentOutOfRangeException), ex.GetType(), "#C2"); Assert.IsNotNull(ex.Message, "#C3"); Assert.IsNotNull(ex.ParamName, "#C4"); Assert.AreEqual("Value", ex.ParamName, "#C5"); Assert.IsNull(ex.InnerException, "#C6"); } nud.BeginInit(); nud.Value = 1000; Assert.AreEqual(1000, nud.Value, "#D1"); nud.Value = 1000; Assert.AreEqual(1000, nud.Value, "#D2"); nud.Value = -1000; Assert.AreEqual(-1000, nud.Value, "#D3"); nud.EndInit(); try { nud.Value = -1000; Assert.Fail("#E1"); } catch (ArgumentOutOfRangeException ex) { Assert.AreEqual(typeof(ArgumentOutOfRangeException), ex.GetType(), "#E2"); Assert.IsNotNull(ex.Message, "#E3"); Assert.IsNotNull(ex.ParamName, "#E4"); Assert.AreEqual("Value", ex.ParamName, "#E5"); Assert.IsNull(ex.InnerException, "#E6"); } }
public void NumericUpDown_EndInit() { NumericNew nud = new NumericNew(); nud.TextChanged += new EventHandler(NumericUpDown_TextChanged); nud.ValueChanged += new EventHandler(NumericUpDown_ValueChanged); Assert.AreEqual(2, nud.CallStack.Count, "#A1"); Assert.AreEqual("ValidateEditText", nud.CallStack [0], "#A2"); Assert.AreEqual("UpdateEditText", nud.CallStack [1], "#A3"); Assert.AreEqual(0, nud.Value, "#A4"); Assert.AreEqual(2, nud.CallStack.Count, "#A5"); Assert.AreEqual(0, value_changed, "#A6"); Assert.AreEqual(0, text_changed, "#A7"); // EndInit without corresponding BeginInit nud.EndInit(); Assert.AreEqual(3, nud.CallStack.Count, "#B1"); Assert.AreEqual("UpdateEditText", nud.CallStack [1], "#B2"); Assert.AreEqual(0, nud.Value, "#B3"); Assert.AreEqual(3, nud.CallStack.Count, "#B4"); Assert.AreEqual(0, value_changed, "#B5"); Assert.AreEqual(0, text_changed, "#B6"); }
public void NumericUpDown_EndInit () { NumericNew nud = new NumericNew (); nud.TextChanged += new EventHandler (NumericUpDown_TextChanged); nud.ValueChanged += new EventHandler (NumericUpDown_ValueChanged); Assert.AreEqual (2, nud.CallStack.Count, "#A1"); Assert.AreEqual ("ValidateEditText", nud.CallStack [0], "#A2"); Assert.AreEqual ("UpdateEditText", nud.CallStack [1], "#A3"); Assert.AreEqual (0, nud.Value, "#A4"); Assert.AreEqual (2, nud.CallStack.Count, "#A5"); Assert.AreEqual (0, value_changed, "#A6"); Assert.AreEqual (0, text_changed, "#A7"); // EndInit without corresponding BeginInit nud.EndInit (); Assert.AreEqual (3, nud.CallStack.Count, "#B1"); Assert.AreEqual ("UpdateEditText", nud.CallStack [1], "#B2"); Assert.AreEqual (0, nud.Value, "#B3"); Assert.AreEqual (3, nud.CallStack.Count, "#B4"); Assert.AreEqual (0, value_changed, "#B5"); Assert.AreEqual (0, text_changed, "#B6"); }
public void NumericUpDown_BeginInit () { NumericNew nud = new NumericNew (); nud.TextChanged += new EventHandler (NumericUpDown_TextChanged); nud.ValueChanged += new EventHandler (NumericUpDown_ValueChanged); Assert.AreEqual (2, nud.CallStack.Count, "#A1"); Assert.AreEqual ("ValidateEditText", nud.CallStack [0], "#A2"); Assert.AreEqual ("UpdateEditText", nud.CallStack [1], "#A3"); Assert.AreEqual (0, nud.Value, "#A4"); Assert.AreEqual (2, nud.CallStack.Count, "#A5"); Assert.AreEqual (0, value_changed, "#A6"); Assert.AreEqual (0, text_changed, "#A7"); nud.BeginInit (); Assert.AreEqual (2, nud.CallStack.Count, "#B1"); nud.Value = 10; Assert.AreEqual (3, nud.CallStack.Count, "#B2"); Assert.AreEqual ("UpdateEditText", nud.CallStack [2], "#B3"); Assert.AreEqual ("0", nud.Text, "#B4"); Assert.AreEqual (10, nud.Value, "#B5"); Assert.AreEqual (3, nud.CallStack.Count, "#B6"); Assert.AreEqual (1, value_changed, "#B7"); Assert.AreEqual (0, text_changed, "#B8"); nud.EndInit (); Assert.AreEqual (4, nud.CallStack.Count, "#B9"); Assert.AreEqual ("UpdateEditText", nud.CallStack [3], "#B10"); Assert.AreEqual (1, text_changed, "#B11"); Assert.AreEqual ("10", nud.Text, "#B12"); Assert.AreEqual (10, nud.Value, "#B13"); Assert.AreEqual (4, nud.CallStack.Count, "#B14"); Assert.AreEqual (1, value_changed, "#B15"); Assert.AreEqual (1, text_changed, "#B16"); // multiple calls to BeginInit are undone by a single EndInit call nud.BeginInit (); nud.BeginInit (); Assert.AreEqual (4, nud.CallStack.Count, "#C1"); nud.Value = 20; Assert.AreEqual (5, nud.CallStack.Count, "#C2"); Assert.AreEqual ("UpdateEditText", nud.CallStack [4], "#C3"); Assert.AreEqual ("10", nud.Text, "#C4"); Assert.AreEqual (20, nud.Value, "#C5"); Assert.AreEqual (5, nud.CallStack.Count, "#C6"); Assert.AreEqual (2, value_changed, "#C7"); Assert.AreEqual (1, text_changed, "#C8"); nud.EndInit (); Assert.AreEqual (6, nud.CallStack.Count, "#C9"); Assert.AreEqual ("UpdateEditText", nud.CallStack [5], "#C10"); Assert.AreEqual (2, text_changed, "#C11"); Assert.AreEqual ("20", nud.Text, "#C12"); Assert.AreEqual (20, nud.Value, "#C13"); Assert.AreEqual (6, nud.CallStack.Count, "#C14"); Assert.AreEqual (2, value_changed, "#C15"); Assert.AreEqual (2, text_changed, "#C16"); }
public void NumericUpDown_Value_Invalid () { NumericNew nud = new NumericNew (); try { nud.Value = 1000; Assert.Fail ("#A1"); } catch (ArgumentOutOfRangeException ex) { Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#A2"); Assert.IsNotNull (ex.Message, "#A3"); Assert.IsNotNull (ex.ParamName, "#A4"); Assert.AreEqual ("Value", ex.ParamName, "#A5"); Assert.IsNull (ex.InnerException, "#A6"); } try { nud.Value = 1000; Assert.Fail ("#B1"); } catch (ArgumentOutOfRangeException ex) { Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#B2"); Assert.IsNotNull (ex.Message, "#B3"); Assert.IsNotNull (ex.ParamName, "#B4"); Assert.AreEqual ("Value", ex.ParamName, "#B5"); Assert.IsNull (ex.InnerException, "#B6"); } try { nud.Value = -1000; Assert.Fail ("#C1"); } catch (ArgumentOutOfRangeException ex) { Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#C2"); Assert.IsNotNull (ex.Message, "#C3"); Assert.IsNotNull (ex.ParamName, "#C4"); Assert.AreEqual ("Value", ex.ParamName, "#C5"); Assert.IsNull (ex.InnerException, "#C6"); } nud.BeginInit (); nud.Value = 1000; Assert.AreEqual (1000, nud.Value, "#D1"); nud.Value = 1000; Assert.AreEqual (1000, nud.Value, "#D2"); nud.Value = -1000; Assert.AreEqual (-1000, nud.Value, "#D3"); nud.EndInit (); try { nud.Value = -1000; Assert.Fail ("#E1"); } catch (ArgumentOutOfRangeException ex) { Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#E2"); Assert.IsNotNull (ex.Message, "#E3"); Assert.IsNotNull (ex.ParamName, "#E4"); Assert.AreEqual ("Value", ex.ParamName, "#E5"); Assert.IsNull (ex.InnerException, "#E6"); } }