56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
|
namespace MatrixProject.Test;
|
||
|
|
||
|
public class MatrixTest
|
||
|
{
|
||
|
[InlineData(10)]
|
||
|
[InlineData(5)]
|
||
|
[InlineData(2)]
|
||
|
[InlineData(3)]
|
||
|
[Theory]
|
||
|
public void CheckRowsBeforeInitMatrixWithRows(int size)
|
||
|
{
|
||
|
Matrix matrix = new Matrix(size);
|
||
|
|
||
|
Assert.Equal(size, matrix.Rows);
|
||
|
Assert.Equal(size, matrix.Columns);
|
||
|
|
||
|
}
|
||
|
|
||
|
[Fact]
|
||
|
public void CheckColumnsBeforeInitMatrix()
|
||
|
{
|
||
|
Matrix matrix = new Matrix();
|
||
|
|
||
|
Assert.Equal(5, matrix.Columns);
|
||
|
}
|
||
|
|
||
|
[Fact]
|
||
|
public void CheckFillMatrixInDefaultConstructor() {
|
||
|
|
||
|
Matrix matrix = new Matrix();
|
||
|
|
||
|
double[,] testMatrix = new double[,] {
|
||
|
{ 1, 1, 1, 1, 1},
|
||
|
{ 1, 1, 1, 1, 1},
|
||
|
{ 1, 1, 1, 1, 1},
|
||
|
{ 1, 1, 1, 1, 1},
|
||
|
{ 1, 1, 1, 1, 1}
|
||
|
};
|
||
|
|
||
|
|
||
|
Assert.True(EqualsTwoDimArray(testMatrix, matrix));
|
||
|
}
|
||
|
|
||
|
private bool EqualsTwoDimArray(double[,] testMatrix, Matrix matrix) {
|
||
|
if(testMatrix.GetLength(0) != matrix.Rows ||
|
||
|
testMatrix.GetLength(1) != matrix.Columns) return false;
|
||
|
for (int i = 0; i < matrix.Rows; i++)
|
||
|
{
|
||
|
for (int j = 0; j < matrix.Columns; j++)
|
||
|
{
|
||
|
if (testMatrix[i, j] != matrix[i, j]) return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
}
|