Ejemplo n.º 1
0
        public void ThrowException()
        {
            //Arrange
            int[] firstArray  = new[] { 4, 3, -2, 1 };
            var   firstMatrix = new SmartMatrix(firstArray);

            int[] secondArray  = new[] { 2, 5, 3 };
            var   secondMatrix = new SmartMatrix(secondArray);

            int[] arraySum       = new[] { 6, 8, 1 };
            var   expectedMatrix = new SmartMatrix(arraySum);

            //Act
            Assert.Throws <ArgumentException>(() => { var result = firstMatrix + secondMatrix; });
        }
Ejemplo n.º 2
0
        public void MultiplyingTwoMatrixes_GetMatrixMultiplication()
        {
            //Arrange
            int[] firstArray  = new[] { 4, 3, -2 };
            var   firstMatrix = new SmartMatrix(firstArray);

            int[] secondArray  = new[] { 2, 5, 3 };
            var   secondMatrix = new SmartMatrix(secondArray);

            var expectedInt = 17;

            //Act
            var result = firstMatrix * secondMatrix;

            //Assert
            Assert.AreEqual(expectedInt, result);
        }
Ejemplo n.º 3
0
        public void AddingTwoMatrixes_GetMatrixSum()
        {
            //Arrange
            int[] firstArray  = new [] { 4, 3, -2 };
            var   firstMatrix = new SmartMatrix(firstArray);

            int[] secondArray  = new [] { 2, 5, 3 };
            var   secondMatrix = new SmartMatrix(secondArray);

            int[] arraySum       = new[] { 6, 8, 1 };
            var   expectedMatrix = new SmartMatrix(arraySum);

            //Act
            var result = firstMatrix + secondMatrix;

            //Assert
            Assert.AreEqual(expectedMatrix, result);
        }
Ejemplo n.º 4
0
        public void SubstractingTwoMatrixes_GetMatrixSubstraction()
        {
            //Arrange
            int[] firstArray  = new[] { 4, 3, -2 };
            var   firstMatrix = new SmartMatrix(firstArray);

            int[] secondArray  = new[] { 2, 5, 3 };
            var   secondMatrix = new SmartMatrix(secondArray);

            int[] arraySubstraction = new[] { 2, -2, -5 };
            var   expectedMatrix    = new SmartMatrix(arraySubstraction);

            //Act
            var result = firstMatrix - secondMatrix;

            //Assert
            Assert.AreEqual(expectedMatrix, result);
        }