first commit
This commit is contained in:
commit
612b1273c9
BIN
MatrixSol/.DS_Store
vendored
Normal file
BIN
MatrixSol/.DS_Store
vendored
Normal file
Binary file not shown.
27
MatrixSol/MatrixProject.Test/MatrixProject.Test.csproj
Normal file
27
MatrixSol/MatrixProject.Test/MatrixProject.Test.csproj
Normal file
@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="xunit" Version="2.5.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MatrixProject\MatrixProject.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
164
MatrixSol/MatrixProject.Test/MatrixTest.cs
Normal file
164
MatrixSol/MatrixProject.Test/MatrixTest.cs
Normal file
@ -0,0 +1,164 @@
|
||||
using MatrixProject.Exceptions;
|
||||
|
||||
namespace MatrixProject.Test;
|
||||
|
||||
public class UnitTest1
|
||||
{
|
||||
[InlineData(10)]
|
||||
[InlineData(5)]
|
||||
[InlineData(2)]
|
||||
[InlineData(3)]
|
||||
[Theory]
|
||||
public void CheckRowsBeforeInitMatrix(int size)
|
||||
{
|
||||
Matrix matrix = new Matrix(size);
|
||||
|
||||
Assert.Equal(size, matrix.Rows);
|
||||
Assert.Equal(size, matrix.Columns);
|
||||
|
||||
}
|
||||
[InlineData(10, 10)]
|
||||
[InlineData(5, 5)]
|
||||
[InlineData(2, 2)]
|
||||
[InlineData(3, 3)]
|
||||
[Theory]
|
||||
public void CheckColumnsBeforeInitMatrix(int rows, int columns)
|
||||
{
|
||||
Matrix matrix = new Matrix(rows, columns);
|
||||
|
||||
Assert.Equal(columns, matrix.Columns);
|
||||
}
|
||||
[Theory]
|
||||
[MemberData(nameof(testTwoDimArray))]
|
||||
|
||||
public void CheckFillMatrixInDefaultConstructor(int rows, int columns, int fillNumber, double[,] testArray) {
|
||||
|
||||
Matrix matrix = new Matrix(rows, columns, fillNumber);
|
||||
|
||||
Assert.True(EqualsTwoDimArray(testArray, matrix));
|
||||
}
|
||||
|
||||
public static TheoryData<int, int,int, double[,]> testTwoDimArray => new () {
|
||||
|
||||
{2, 2, 3, new double[,] { { 3, 3 }, { 3, 3 } } }
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
[Theory]
|
||||
[MemberData(nameof(testMultiplyDigit))]
|
||||
public void CheackMultiplyMatrixByDigit(int row, int column, int fillNumber, int scalar, double[,] testArray) {
|
||||
|
||||
Matrix matrix = new Matrix(row, column, fillNumber);
|
||||
matrix *= scalar;
|
||||
Assert.True(EqualsTwoDimArray(testArray, matrix));
|
||||
|
||||
}
|
||||
public static TheoryData<int, int, int, int, double[,]> testMultiplyDigit => new () {
|
||||
|
||||
{ 2, 2, 2, 2, new double[,] { { 4, 4 }, { 4, 4 } } }
|
||||
};
|
||||
[Theory]
|
||||
[MemberData(nameof(testSumException))]
|
||||
public void CheckSumWithException(Matrix matrix, Matrix matrix1) {
|
||||
|
||||
Assert.Throws<AdditionException>(() => matrix += matrix1);
|
||||
|
||||
}
|
||||
public static TheoryData<Matrix, Matrix> testSumException => new() {
|
||||
{new Matrix(4, 3), new Matrix(3, 4)}
|
||||
};
|
||||
[Theory]
|
||||
[MemberData(nameof(testSum))]
|
||||
public void CheckSum(Matrix matrix, Matrix matrix1, double[,] testArray) {
|
||||
|
||||
matrix += matrix1;
|
||||
Assert.True(EqualsTwoDimArray(testArray, matrix));
|
||||
}
|
||||
public static TheoryData<Matrix, Matrix, double[,]> testSum => new() {
|
||||
|
||||
{ new Matrix(2, 2, 3), new Matrix(2, 2, 2), new double[,] {{5, 5}, {5, 5}}}
|
||||
};
|
||||
[Theory]
|
||||
[MemberData(nameof(testGetRow))]
|
||||
public void CheckGetRowByIndex(Matrix matrix, int row, double[] resultRow) {
|
||||
|
||||
Assert.Equal(matrix.GetRowByIndex(row), resultRow);
|
||||
}
|
||||
public static TheoryData<Matrix, int, double[]> testGetRow => new()
|
||||
{
|
||||
{ new Matrix(2, 2, 2), 0, new double[] {2, 2}}
|
||||
};
|
||||
[Theory]
|
||||
[MemberData(nameof(testGetColumn))]
|
||||
public void CheckGetColumnByIndex(Matrix matrix, int column, double[] resultColumn) {
|
||||
|
||||
Assert.Equal(matrix.GetColumnByIndex(column), resultColumn);
|
||||
|
||||
}
|
||||
public static TheoryData<Matrix, int, double[]> testGetColumn => new()
|
||||
{
|
||||
{ new Matrix(2, 2, 2), 0, new double[] {2, 2}}
|
||||
};
|
||||
[Theory]
|
||||
[MemberData(nameof(testMultiplyTwoMatrix))]
|
||||
public void CheckMultiplyTwoMatrix(Matrix matrixOne, Matrix matrixTwo, double[,] testMultiply) {
|
||||
|
||||
double[,] result = matrixOne * matrixTwo;
|
||||
|
||||
Assert.Equal(result, testMultiply);
|
||||
|
||||
}
|
||||
public static TheoryData<Matrix, Matrix, double[,]> testMultiplyTwoMatrix => new()
|
||||
{
|
||||
{ new Matrix(2, 2, 2), new Matrix(2, 2, 3), new double[,] {{12, 12}, {12, 12}}}
|
||||
};
|
||||
[Theory]
|
||||
[MemberData(nameof(testDiagonale))]
|
||||
public void CheckDiagonaleMatrix(Matrix matrix, double[,] answer) {
|
||||
|
||||
matrix.ConvertToDiagonaleMatrix(matrix);
|
||||
Assert.True(EqualsTwoDimArray(answer, matrix));
|
||||
|
||||
}
|
||||
public static TheoryData<Matrix, double[,]> testDiagonale => new()
|
||||
{
|
||||
{ new Matrix( new double[,]{{20, 30, 30}, {10, 20, 30}, {10, 40, 20}}), new double[,] { {20, 30, 30}, {0, 5, 15}, {0, 0, -70}}}
|
||||
};
|
||||
[Theory]
|
||||
[MemberData(nameof(testDeterminant))]
|
||||
public void CheckDeterminantMatrix(Matrix matrix, double answer) {
|
||||
|
||||
matrix.ConvertToDiagonaleMatrix(matrix);
|
||||
double res = matrix.GetDeterminantMatrix(matrix);
|
||||
|
||||
Assert.Equal(answer, res);
|
||||
|
||||
}
|
||||
public static TheoryData<Matrix, double> testDeterminant => new()
|
||||
{
|
||||
{ new Matrix( new double[,]{{20, 30, 30}, {10, 20, 30}, {10, 40, 20}}), -7000}
|
||||
};
|
||||
[Theory]
|
||||
[MemberData(nameof(testToString))]
|
||||
public void CheckToStringMatrix(Matrix matrix, string answer) {
|
||||
|
||||
string res = matrix.ToString();
|
||||
Assert.Equal(answer, res);
|
||||
|
||||
}
|
||||
public static TheoryData<Matrix, string> testToString => new()
|
||||
{
|
||||
{ new Matrix(3, 3, 2), "2 2 2 \n2 2 2 \n2 2 2 \n"}
|
||||
};
|
||||
}
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@ -0,0 +1,12 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net8.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "8.0.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||
}
|
||||
}
|
||||
}
|
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/MatrixProject.dll
Normal file
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/MatrixProject.dll
Normal file
Binary file not shown.
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/MatrixProject.pdb
Normal file
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/MatrixProject.pdb
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/Newtonsoft.Json.dll
Executable file
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/Newtonsoft.Json.dll
Executable file
Binary file not shown.
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/NuGet.Frameworks.dll
Executable file
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/NuGet.Frameworks.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/testhost.dll
Executable file
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/testhost.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/xunit.abstractions.dll
Executable file
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/xunit.abstractions.dll
Executable file
Binary file not shown.
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/xunit.assert.dll
Executable file
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/xunit.assert.dll
Executable file
Binary file not shown.
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/xunit.core.dll
Executable file
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/xunit.core.dll
Executable file
Binary file not shown.
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/xunit.execution.dotnet.dll
Executable file
BIN
MatrixSol/MatrixProject.Test/bin/Debug/net8.0/xunit.execution.dotnet.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
|
@ -0,0 +1,22 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("MatrixProject.Test")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("MatrixProject.Test")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("MatrixProject.Test")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Создано классом WriteCodeFragment MSBuild.
|
||||
|
@ -0,0 +1 @@
|
||||
4b30ebc250ee42c3b9faa54f23b0864a8e7ee790a1e18a0978b32da43b8dc4a1
|
@ -0,0 +1,13 @@
|
||||
is_global = true
|
||||
build_property.TargetFramework = net8.0
|
||||
build_property.TargetPlatformMinVersion =
|
||||
build_property.UsingMicrosoftNETSdkWeb =
|
||||
build_property.ProjectTypeGuids =
|
||||
build_property.InvariantGlobalization =
|
||||
build_property.PlatformNeutralAssembly =
|
||||
build_property.EnforceExtendedAnalyzerRules =
|
||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||
build_property.RootNamespace = MatrixProject.Test
|
||||
build_property.ProjectDir = /Users/feitanportor/dev/C#/MatrixProject/MatrixSol/MatrixProject.Test/
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
@ -0,0 +1,9 @@
|
||||
// <auto-generated/>
|
||||
global using global::System;
|
||||
global using global::System.Collections.Generic;
|
||||
global using global::System.IO;
|
||||
global using global::System.Linq;
|
||||
global using global::System.Net.Http;
|
||||
global using global::System.Threading;
|
||||
global using global::System.Threading.Tasks;
|
||||
global using global::Xunit;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user