Wraps a NumericUpDown control in order to display and capture a currency property of the business object, where values are rounded to two decimal places
Inheritance: NumericUpDownMapper
コード例 #1
0
        public void TestSetBusinessObject()
        {
            //---------------Set up test pack-------------------
            INumericUpDown numUpDown = GetControlFactory().CreateNumericUpDownCurrency();
            NumericUpDownCurrencyMapper mapper =
                new NumericUpDownCurrencyMapper(numUpDown, CURRENCY_PROP_NAME, false, GetControlFactory());
            Sample s = new Sample();
            decimal val = 100.5m;
            s.SampleMoney = val;
            //---------------Execute Test ----------------------
            mapper.BusinessObject = s;
            //---------------Test Result -----------------------
            Assert.AreEqual(val, numUpDown.Value, "Value is not set.");

            //---------------Tear Down -------------------------
        }
コード例 #2
0
 public void Test_BusinessObjectChanged_UpdatesControl()
 {
     //---------------Set up test pack-------------------
     INumericUpDown numUpDown = GetControlFactory().CreateNumericUpDownInteger();
     NumericUpDownCurrencyMapper mapper =
         new NumericUpDownCurrencyMapper(numUpDown, CURRENCY_PROP_NAME, false, GetControlFactory());
     Sample s = new Sample();
     s.SampleMoney = 100.10m;
     mapper.BusinessObject = s;
     //---------------Execute Test ----------------------
     decimal newValue = 555.45m;
     s.SampleMoney = newValue;
     //---------------Test Result -----------------------
     Assert.AreEqual(newValue, numUpDown.Value);
     //---------------Tear down -------------------------
 }
コード例 #3
0
        public void TestConstructor()
        {
            //---------------Set up test pack-------------------
            INumericUpDown numUpDown = GetControlFactory().CreateNumericUpDownCurrency();
            //---------------Execute Test ----------------------
            NumericUpDownCurrencyMapper mapper =
                new NumericUpDownCurrencyMapper(numUpDown, CURRENCY_PROP_NAME, false, GetControlFactory());

            //---------------Test Result -----------------------
            Assert.AreSame(numUpDown, mapper.Control);
            Assert.AreSame(CURRENCY_PROP_NAME, mapper.PropertyName);
            Assert.AreEqual(2, numUpDown.DecimalPlaces);
            Assert.AreEqual(decimal.MinValue, numUpDown.Minimum);
            Assert.AreEqual(decimal.MaxValue, numUpDown.Maximum);

            //---------------Tear Down -------------------------
        }
コード例 #4
0
 public void Test_ValueChangedEvent_UpdatesBusinessObject()
 {
     //---------------Set up test pack-------------------
     INumericUpDown numUpDown = GetControlFactory().CreateNumericUpDownCurrency();
     NumericUpDownCurrencyMapper mapper =
         new NumericUpDownCurrencyMapper(numUpDown, CURRENCY_PROP_NAME, false, GetControlFactory());
     Sample s = new Sample();
     s.SampleMoney = 100.10m;
     mapper.BusinessObject = s;
     //---------------Execute Test ----------------------
     decimal newValue = 555.45m;
     numUpDown.Value = newValue;
     //---------------Test Result -----------------------
     Assert.IsInstanceOf(typeof(NumericUpDownMapperStrategyWin), mapper.MapperStrategy);
     Assert.AreEqual(newValue, s.SampleMoney);
     //---------------Tear down -------------------------
 }