-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02)N-Arg_Demo.cs
40 lines (31 loc) · 1.52 KB
/
02)N-Arg_Demo.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
namespace ExtensionsTests.Exceptions;
public class NArg_Demo
{
[Test]
public void ReportArgumentsCallers() {
const string dummy = "NOT_IN_OUTPUT";
var dummyStruct = new System.Drawing.Point(7, -12);
var exc = Assert.Throws<ArgumentException>(() =>
Argument.Throw("Motley args to be recorded by caller",
dummyStruct, 1, dummy, this, true, "literal", long.MinValue, 3 + 5, () => double.Epsilon * Math.E));
Assert.That(exc?.Message, Contains.Substring(nameof(dummy)));
Assert.That(exc?.Message, Does.Not.Contains(dummy));
Assert.That(exc?.Message, Contains.Substring("literal"));
Assert.That(exc?.Message, Contains.Substring("this"));
Assert.That(exc?.Message, Contains.Substring(nameof(dummyStruct)));
Assert.That(exc?.Message, Does.Not.Contains(dummyStruct.ToString()));
Assert.That(exc?.Message, Contains.Substring("Epsilon"));
}
[Test]
public void CustomMultiparam() {
const float measure = 2.22f;
var varied = "info";
var objRef = new object();
var exc = Assert.Throws<MyCustomMultiaparamException>(() =>
MyCustomMultiaparamException.Throw("report multiple params of various types",
objRef, "message", measure, varied, byte.MinValue, 7));
Assert.That(exc?.Message, Is.Not.Empty);
}
class MyCustomMultiaparamException(string? message = "", Exception? inner = null)
: Multiparameter<MyCustomMultiaparamException>(message, inner);
}