示例#1
0
        public void DivisionByZeroTest()
        {
            //we expect that yesno should throw and exception but number and text should add, resp. concat.

            NumberWrapper na = new NumberWrapper(12345);
            NumberWrapper nb = new NumberWrapper(0);
            bool exceptionRaised = false;
            try{
                var c = na/nb;
            }
            catch (Exception e){
                Assert.IsInstanceOfType(e, typeof(DivisionByZeroError));
                exceptionRaised = true;
            }
            Assert.IsTrue(exceptionRaised,"No exception has  been raised");
        }
示例#2
0
        public void EvaluatedValueComparisson()
        {
            YesnoWrapper yes = new YesnoWrapper(true);
            YesnoWrapper no = new YesnoWrapper(false);
            NumberWrapper a = new NumberWrapper(12345);
            NumberWrapper b = new NumberWrapper(12345);

            Assert.IsTrue((a == b).ToBool());
            Number n = new Number();
            n.Value = 12345;
            NumberWrapper c = new NumberWrapper(n);
            Assert.IsTrue((c == a).ToBool());
            Assert.IsFalse((c != a).ToBool());

            b.Value = 23456;
            Assert.IsFalse((c == b).ToBool());
            Assert.IsTrue((c != b).ToBool());
        }
示例#3
0
        public void PlusOperatorTest()
        {
            //we expect that yesno should throw and exception but number and text should add, resp. concat.

            NumberWrapper na = new NumberWrapper(12345);
            NumberWrapper nb = new NumberWrapper(12345);

            TextWrapper ta = new TextWrapper("bla");
            TextWrapper tb = new TextWrapper("ble");

            Assert.AreEqual(24690, (na + nb).Value);
            Assert.AreEqual("blable", (ta + tb).Value);
        }
示例#4
0
 public WidgetBase GetWidget(QuestionUnit unit, NumberWrapper typeWrapper)
 {
     unit.InitialiseValue(typeWrapper);
     return new NumberWidget(unit);
 }
示例#5
0
 protected static bool ContainsNullValue(NumberWrapper a, NumberWrapper b)
 {
     return ReferenceEquals(a, null) || ReferenceEquals(b, null) || ReferenceEquals(null, a.Value) || ReferenceEquals(null, b.Value);
 }
示例#6
0
 public bool Equals(NumberWrapper obj)
 {
     return Value == obj.Value;
 }
 protected static bool ContainsNullValue(NumberWrapper a, NumberWrapper b)
 {
     return(ReferenceEquals(a, null) || ReferenceEquals(b, null) || ReferenceEquals(null, a.Value) || ReferenceEquals(null, b.Value));
 }
 public bool Equals(NumberWrapper obj)
 {
     return(Value == obj.Value);
 }