コード例 #1
0
        public void AddNumbers()
        {
            AddOperation op = AddOperation.Instance;

            Assert.AreEqual(1 + 2, op.Apply(1, 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));
        }
コード例 #2
0
        public void AddRealToVector()
        {
            AddOperation op = AddOperation.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 + 1.5, vector[0]);
            Assert.AreEqual(2 + 1.5, vector[1]);
            Assert.AreEqual(3 + 1.5, vector[2]);
        }
コード例 #3
0
        public void AddVectorToInteger()
        {
            AddOperation op = AddOperation.Instance;

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

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

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

            var vector = (Vector)result;

            Assert.AreEqual(3, vector.Length);
            Assert.AreEqual(2, vector[0]);
            Assert.AreEqual(3, vector[1]);
            Assert.AreEqual(4, vector[2]);
        }
コード例 #4
0
        public void AddOperation_TwoMatricesWithDifferentOrder_OrderDoesNotMatter(int i1, int i2)
        {
            var matrix1 = new Matrix(new int[1, 1] {
                { i1 }
            });
            var matrix2 = new Matrix(new int[1, 1] {
                { i2 }
            });
            var expectedMatrix = new Matrix(new int[1, 1] {
                { i1 + i2 }
            });

            var inputArray    = new Matrix[] { matrix1, matrix2 };
            var expectedArray = new Matrix[] { expectedMatrix };

            var opratrion = new AddOperation();

            var output = opratrion.Apply(inputArray);

            Assert.Equal(expectedArray, output, new MatrixComparer());
        }
コード例 #5
0
        public void AddOperation_TwoMatrices_MatricesAdded()
        {
            var matrix1 = new Matrix(new int[2, 2] {
                { 1, 2 }, { 3, 4 }
            });
            var matrix2 = new Matrix(new int[2, 2] {
                { 1, 2 }, { 3, 4 }
            });
            var expectedMatrix = new Matrix(new int[2, 2] {
                { 2, 4 }, { 6, 8 }
            });

            var inputArray    = new Matrix[] { matrix1, matrix2 };
            var expectedArray = new Matrix[] { expectedMatrix };

            var opratrion = new AddOperation();

            var output = opratrion.Apply(inputArray);

            Assert.Equal(expectedArray, output, new MatrixComparer());
        }
コード例 #6
0
ファイル: Schedule.cs プロジェクト: jesper-sk/AfvalOphaler
 protected override void _Apply() => addOp.Apply();