I have a simple program that uses List to store matrixes; this part is used to calculate a number of elements that are more then 3,15. It does what it needs to do but when it comes to testing i'm hit with endless loading with no errors showing.
I'm completely new to this so i need someone to help me out.
namespace MatrixLib
{
public class Matrix
{
public static List<Matrix> matrixes = new List<Matrix>();
public int[,] matrix;
public int rows;
public int columns;
}
public class DoMatrix
{
public static int Calculate(List<Matrix> matrixes, int indexOne)
{
int count = 0;
for (int i = 0; i < matrixes[indexOne].rows; i++)
{
for (int j = 0; j < matrixes[indexOne].columns; j++)
{
if (matrixes[indexOne].matrix[i, j] > 3.5)
count += 1;
}
}
Console.WriteLine("\nМатрица номер " + indexOne + " содержит " + count + " элементов больших 3.5");
Console.ReadKey();
return(count);
}
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MatrixLib;
namespace MatrixTest
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var expected = 0;
List<Matrix> matrixes = new List<Matrix>();
matrixes.Add(new Matrix() { matrix = new int[2, 2] { { 0, 1 }, { 2, 3 } }, rows = 2, columns = 2 });
var result = DoMatrix.Calculate(matrixes, 0);
Assert.AreEqual(expected, result);
}
}