public void SubtractNumbers() { SubtractOperation op = SubtractOperation.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)); }
public void SubtractVectorFromReal() { SubtractOperation op = SubtractOperation.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(0.5, vector[0]); Assert.AreEqual(-0.5, vector[1]); Assert.AreEqual(-1.5, vector[2]); }
public void SubtractOperation_TwoMatrices_MatricesSubtracted() { 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] { { 0, 0 }, { 0, 0 } }); var inputArray = new Matrix[] { matrix1, matrix2 }; var expectedArray = new Matrix[] { expectedMatrix }; var opratrion = new SubtractOperation(); var output = opratrion.Apply(inputArray); Assert.Equal(expectedArray, output, new MatrixComparer()); }