-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSnippets.txt
More file actions
64 lines (45 loc) · 1.68 KB
/
Copy pathSnippets.txt
File metadata and controls
64 lines (45 loc) · 1.68 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
1---------------------------------------------------------------------------------------
public int Subtract(int value1, int value2)
{
return checked(value1 - value2);
}
2---------------------------------------------------------------------------------------
[Theory]
[InlineData(10, 5, 5)]
[InlineData(2, 1, 1)]
[InlineData(4, 3, 1)]
public void Subtract_ShouldReturnTheDifference(int value1, int value2, int expected)
{
var calculator = new Calculator();
var result = calculator.Subtract(value1, value2);
Assert.Equal(expected, result);
}
3---------------------------------------------------------------------------------------
if (value1 < 0)
throw new ArgumentOutOfRangeException(nameof(value1), "Negative value");
if (value2 < 0)
throw new ArgumentOutOfRangeException(nameof(value2), "Negative value");
4---------------------------------------------------------------------------------------
[Fact]
public void Add_ShouldThrowWithNegativeValue1()
{
var value1 = -2;
var value2 = 1;
var calculator = new Calculator();
void Action() => calculator.Add(value1, value2);
Assert.Throws<ArgumentOutOfRangeException>(Action);
}
5---------------------------------------------------------------------------------------
[Fact]
public void Add_ShouldThrowWithNegativeValue2()
{
var value1 = 2;
var value2 = -1;
var calculator = new Calculator();
void Action() => calculator.Add(value1, value2);
Assert.Throws<ArgumentOutOfRangeException>(Action);
}
6----------------------------------------------------------------------------------------
[ExcludeFromCodeCoverage]
7----------------------------------------------------------------------------------------
SELECT SETTINGSFILE (RegEx)