-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathTests.cs
More file actions
77 lines (63 loc) · 1.6 KB
/
MathTests.cs
File metadata and controls
77 lines (63 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using Xunit;
using Shouldly;
namespace ModuleTests;
public class MathTests
{
[Fact]
[Trait("Category", "Unit")]
public void SolveQaudratic_WithPositive_C_Argument_Should_ReturnEmpty()
{
// Arange
var b = -1; // x2 + 1 = 0;
// Act
var result = QuadraticHelper.SolveIncompleteQuadraticEquation(b);
// Assert
result.Length.ShouldBe(0);
}
[Fact]
[Trait("Category", "Unit")]
public void SolveQaudratic_WithPositive_C_Argument_Should_ReturnTwoRoots()
{
// Arange
var b = 1;
// Act
var result = QuadraticHelper.SolveIncompleteQuadraticEquation(b);
// Assert
result.Length.ShouldBe(2);
result[1].ShouldBe(result[0] * -1);
}
[Fact]
[Trait("Category", "Unit")]
public void SolveQaudratic_WithPositive_C_Argument_Should_ReturnOneSameRoot()
{
// Arange
// x ^ 2 + 2x + 1 = 0
var a = 1;
var b = -2;
var c = 1;
// Act
var result = QuadraticHelper.Solve(a, b, c);
// Assert
result.Length.ShouldBe(2);
result[1].ShouldBe(result[0]);
}
[Fact]
[Trait("Category", "Unit")]
public void SolveQaudratic_WithPositive_A_Argument_Should_NotBeNull()
{
// Arange
// x ^ 2 + 2x + 1 = 0
var a = 0;
var b = -2;
var c = 1;
// Act
try
{
var result = QuadraticHelper.Solve(a, b, c);
}catch(Exception e)
{
// Assert
e.Message.ShouldBe("Argument a can not be 0");
}
}
}