Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions UnitTesting/joil/LabWork6.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using TestingLib.Math;

namespace UnitTesting.joil
{
public class LabWork6
{
private readonly BasicCalc _calculator;

public LabWork6()
{
_calculator = new BasicCalc();
}

[Fact]
public void Sqrt_ShouldReturnCorrectSqrt()
{
double calc = _calculator.Sqrt(144);
Assert.Equal(12, calc);
}

[Theory]
[InlineData(144, 12)]
[InlineData(0, 0)]
[InlineData(3, 1.732)]
public void Sqrt_Theory(double a, double expectedResult)
{
double calc = _calculator.Sqrt(a);
Assert.Equal(expectedResult, calc, 0.001);
}

[Fact]
public void Sqrt_ShouldThrowException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => _calculator.Sqrt(-25));
}

[Fact]
public void IsPrime_ShouldReturnTrueIfPrime()
{
bool calc = _calculator.IsPrime(5);
Assert.Equal(true, calc);
}

[Theory]
[InlineData(5, true)]
[InlineData(6, false)]
[InlineData(1, false)]
public void IsPrime_Theory(int a, bool expectedResult)
{
bool calc = _calculator.IsPrime(a);
Assert.Equal(expectedResult, calc);
}

[Fact]
public void IsPrime_ShouldThrowException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => _calculator.IsPrime(-2));
}
}
}
1 change: 1 addition & 0 deletions UnitTesting/joil/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
joil - ������� �������� �������������� ����35