Example #1
0
        public void DivideNumbers()
        {
            DivideOperation op = DivideOperation.Instance;

            Assert.AreEqual(1 / 2.0, op.Apply(1, 2));
            Assert.AreEqual(2, op.Apply(4, 2));
            Assert.AreEqual(1.2 / 3.4, op.Apply(1.2, 3.4));
            Assert.AreEqual(1 / 2.3, op.Apply(1, 2.3));
            Assert.AreEqual(1.2 / 3, op.Apply(1.2, 3));
        }
Example #2
0
        public void DivideRealToVector()
        {
            DivideOperation op = DivideOperation.Instance;

            Vector v = new Vector(new object[] { 1, 2, 3 });

            var result = op.Apply(1.5, v);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(Vector));

            var vector = (Vector)result;

            Assert.AreEqual(3, vector.Length);
            Assert.AreEqual(1.5 / 1, vector[0]);
            Assert.AreEqual(1.5 / 2, vector[1]);
            Assert.AreEqual(1.5 / 3, vector[2]);
        }
Example #3
0
        public void DivideVectorByInteger()
        {
            DivideOperation op = DivideOperation.Instance;

            Vector v = new Vector(new object[] { 1, 2, 3 });

            var result = op.Apply(v, 2);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(Vector));

            var vector = (Vector)result;

            Assert.AreEqual(3, vector.Length);
            Assert.AreEqual(1 / 2.0, vector[0]);
            Assert.AreEqual(1, vector[1]);
            Assert.AreEqual(3 / 2.0, vector[2]);
        }