Add tests on new behaviours
This commit is contained in:
parent
b1e4aa29a3
commit
666c78ff59
1 changed files with 21 additions and 9 deletions
|
@ -49,18 +49,16 @@ namespace AspectedRouting.Tests
|
|||
AspectMetadata functionToApply,
|
||||
IEnumerable<(string expected, Dictionary<string, string> tags)> tests)
|
||||
{
|
||||
|
||||
if (functionToApply == null)
|
||||
{
|
||||
throw new NullReferenceException("functionToApply is null");
|
||||
}
|
||||
|
||||
FunctionToApply = functionToApply;
|
||||
Tests = tests;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public bool Run()
|
||||
{
|
||||
var failed = false;
|
||||
|
@ -77,14 +75,28 @@ namespace AspectedRouting.Tests
|
|||
}
|
||||
}
|
||||
|
||||
var actual = FunctionToApply.Evaluate(context, new Constant(test.tags));
|
||||
if (!actual.ToString().Equals(test.expected) &&
|
||||
!(actual is double actualD && Math.Abs(double.Parse(test.expected) - actualD) < 0.0001)
|
||||
)
|
||||
try
|
||||
{
|
||||
var actual = FunctionToApply.Evaluate(context, new Constant(test.tags));
|
||||
if (test.expected == "null" && actual == null)
|
||||
{
|
||||
// Test ok
|
||||
}
|
||||
else if (!actual.ToString().Equals(test.expected) &&
|
||||
!(actual is double actualD && Math.Abs(double.Parse(test.expected) - actualD) < 0.0001)
|
||||
)
|
||||
{
|
||||
failed = true;
|
||||
Console.WriteLine(
|
||||
$"[{FunctionToApply.Name}] Line {testCase + 1} failed:\n Expected: {test.expected}\n actual: {actual}\n tags: {test.tags.Pretty()}\n");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
failed = true;
|
||||
Console.WriteLine(
|
||||
$"[{FunctionToApply.Name}] Line {testCase+1} failed:\n Expected: {test.expected}\n actual: {actual}\n tags: {test.tags.Pretty()}\n");
|
||||
$"[{FunctionToApply.Name}] Line {testCase + 1} ERROR:\n Expected: {test.expected}\n error message: {e.Message}\n tags: {test.tags.Pretty()}\n");
|
||||
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue