Пример #1
0
        public void TrySubtract_Ints_ReturnsDouble()
        {
            int    n1 = 10;
            int    n2 = 12;
            object d;

            Assert.IsTrue(ReflectionMath.TrySubtract(n2, n1, out d));
            Assert.IsTrue(d is int);
            Assert.AreEqual(2, (int)d);
        }
Пример #2
0
        public void TrySubtract_DateTime_ReturnsTimeSpan()
        {
            var    t1 = DateTime.Now;
            var    t2 = t1.AddDays(2);
            object d;

            Assert.IsTrue(ReflectionMath.TrySubtract(t2, t1, out d));
            Assert.IsTrue(d is TimeSpan);
            Assert.AreEqual(2, ((TimeSpan)d).TotalDays);
        }
Пример #3
0
        public void TrySubtract_Doubles_ReturnsDouble()
        {
            double n1 = 10;
            double n2 = 12;
            object d;

            Assert.IsTrue(ReflectionMath.TrySubtract(n2, n1, out d));
            Assert.IsTrue(d is double);
            Assert.AreEqual(2, (double)d);
        }
Пример #4
0
        public void TrySubtract_Points_ReturnsVector()
        {
            var p1 = new Point(10, 10);
            var p2 = new Point(8, 3);
            var d  = p2 - p1;

            object o1 = p1;
            object o2 = p2;
            object d2;

            Assert.IsTrue(ReflectionMath.TrySubtract(o2, o1, out d2));
            Assert.AreEqual(d, d2);
        }
Пример #5
0
        public void TrySubtract_PointFromVector_Fails()
        {
            object r;

            Assert.IsFalse(ReflectionMath.TrySubtract(new Vector(0, 0), new Point(1, 1), out r));
        }