forked from kbester/DebugWorkshop2020Prac3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnitTest1.cs
64 lines (60 loc) · 1.54 KB
/
UnitTest1.cs
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
using Microsoft.VisualStudio.TestTools.UnitTesting;
using debugws3;
namespace Tests
{
[TestClass]
public class ErrorHandling
{
[TestMethod]
public void ShouldErrorOnCrap()
{
var result = Calc.Calculate(null);
Assert.IsFalse(result.err.Length == 0, "should not be empty");
}
[DataTestMethod]
[DataRow("")]
[DataRow("x")]
[DataRow("2z^2+z+c")]
[DataRow("0*FF+1")]
[DataRow("ABC")]
public void DoErrors(string value)
{
var result = Calc.Calculate(value);
Assert.IsFalse(result.err.Length == 0, $"{value} should yield an error");
}
}
[TestClass]
public class Basics
{
[DataTestMethod]
[DataRow("3+3")]
[DataRow("2 + 4")]
[DataRow(" 4+2 ")]
[DataRow("5+ 1")]
[DataRow(" 6 + 0 ")]
public void DoPlus(string value)
{
var result = Calc.Calculate(value);
Assert.IsTrue(result.result == 6, $"{value} should be 6");
}
[DataTestMethod]
[DataRow(" 3-2")]
[DataRow("2- 1")]
[DataRow(" 4 - 3 ")]
[DataRow("5- 4")]
[DataRow(" 6-5")]
public void DoMinus(string value)
{
var result = Calc.Calculate(value);
Assert.IsTrue(result.result == 1, $"{value} should be 1");
}
[DataTestMethod]
[DataRow("3*3+1")]
[DataRow("1+3*3")]
public void DoAddMultipy(string value)
{
var res = Calc.Calculate(value);
Assert.IsTrue(res.result == 10, $"{value} should be 10");
}
}
}