BadScript 2
Loading...
Searching...
No Matches
BadNUnitAssertApi.cs
Go to the documentation of this file.
6
7using NUnit.Framework;
8
10
14[BadInteropApi("Assert")]
15internal partial class BadNUnitAssertApi
16{
23 [BadMethod("Throws", "Asserts that the given function throws a BadRuntimeException")]
24 private static void Assert_Throws(BadExecutionContext ctx,
25 [BadParameter(description: "The Function that is expected to throw")]
26 BadFunction func,
27 [BadParameter(description: "The Message")]
28 string message)
29 {
30 Assert.Throws<BadRuntimeException>(() =>
31 {
32 foreach (BadObject _ in func.Invoke(Array.Empty<BadObject>(), ctx))
33 {
34 //Do Nothing
35 }
36 },
37 message
38 );
39 }
40
47 [BadMethod("AreEqual", "Asserts that the given objects are equal")]
48 private static void Assert_AreEqual([BadParameter(description: "The Expected Value")] BadObject? expected,
49 [BadParameter(description: "The Actual Value")]
50 BadObject? actual,
51 [BadParameter(description: "The Message")]
52 string message)
53 {
54 Assert.That(actual, Is.EqualTo(expected), message);
55 }
56
63 [BadMethod("AreNotEqual", "Asserts that the given objects are not equal")]
64 private static void Assert_AreNotEqual([BadParameter(description: "The Expected Value")] BadObject? expected,
65 [BadParameter(description: "The Actual Value")]
66 BadObject? actual,
67 [BadParameter(description: "The Message")]
68 string message)
69 {
70 Assert.That(actual, Is.Not.EqualTo(expected), message);
71 }
72
79 [BadMethod("AreSame", "Asserts that the given objects are the same")]
80 private static void Assert_AreSame([BadParameter(description: "The Expected Value")] BadObject? expected,
81 [BadParameter(description: "The Actual Value")]
82 BadObject? actual,
83 [BadParameter(description: "The Message")]
84 string message)
85 {
86 Assert.That(actual, Is.SameAs(expected), message);
87 }
88
95 [BadMethod("AreNotSame", "Asserts that the given objects are not the same")]
96 private static void Assert_AreNotSame([BadParameter(description: "The Expected Value")] BadObject? expected,
97 [BadParameter(description: "The Actual Value")]
98 BadObject? actual,
99 [BadParameter(description: "The Message")]
100 string message)
101 {
102 Assert.That(actual, Is.Not.SameAs(expected), message);
103 }
104
110 [BadMethod("IsTrue", "Asserts that the given condition is true")]
111 private static void Assert_IsTrue([BadParameter(description: "The Condition to check")] BadObject? condition,
112 [BadParameter(description: "The Message")] string message)
113 {
114 Assert.That(condition is IBadBoolean { Value: true },
115 Is.True,
116 message
117 );
118 }
119
125 [BadMethod("IsFalse", "Asserts that the given condition is false")]
126 private static void Assert_IsFalse([BadParameter(description: "The Condition to check")] BadObject? condition,
127 [BadParameter(description: "The Message")] string message)
128 {
129 Assert.That(condition is not IBadBoolean b || b.Value, Is.False, message);
130 }
131
132
137 [BadMethod("Fail", "Fails the test with the given message")]
138 private static void Assert_Fail([BadParameter(description: "The Message")] string message)
139 {
140 Assert.Fail(message);
141 }
142
147 [BadMethod("Inconclusive", "Marks the test as inconclusive with the given message")]
148 private static void Assert_Inconclusive([BadParameter(description: "The Message")] string message)
149 {
150 Assert.Inconclusive(message);
151 }
152
157 [BadMethod("Ignore", "Ignore the test with the given message")]
158 private static void Assert_Ignore([BadParameter(description: "The Message")] string message)
159 {
160 Assert.Ignore(message);
161 }
162
163
169 [BadMethod("IsNull", "Asserts that the given object is null")]
170 private static void Assert_IsNull([BadParameter(description: "The Object to check")] BadObject? obj,
171 [BadParameter(description: "The Message")] string message)
172 {
173 Assert.That(obj, Is.Null, message);
174 }
175
181 [BadMethod("IsNotNull", "Asserts that the given object is not null")]
182 private static void Assert_IsNotNull([BadParameter(description: "The Object to check")] BadObject? obj,
183 [BadParameter(description: "The Message")] string message)
184 {
185 Assert.That(obj, Is.Not.Null, message);
186 }
187
194 [BadMethod("Greater", "Asserts that the given object is greater than the other object")]
195 private static void Assert_Greater([BadParameter(description: "Actual")] decimal a,
196 [BadParameter(description: "Expected")]
197 decimal b,
198 [BadParameter(description: "The Message")]
199 string message)
200 {
201 Assert.That(a, Is.GreaterThan(b), message);
202 }
203
210 [BadMethod("GreaterOrEqual", "Asserts that the given object is greater or equal the other object")]
211 private static void Assert_GreaterOrEqual([BadParameter(description: "Actual")] decimal a,
212 [BadParameter(description: "Expected")]
213 decimal b,
214 [BadParameter(description: "The Message")]
215 string message)
216 {
217 Assert.That(a, Is.GreaterThanOrEqualTo(b), message);
218 }
219
226 [BadMethod("Less", "Asserts that the given object is less than the other object")]
227 private static void Assert_Less([BadParameter(description: "Actual")] decimal a,
228 [BadParameter(description: "Expected")]
229 decimal b,
230 [BadParameter(description: "The Message")]
231 string message)
232 {
233 Assert.That(a, Is.LessThan(b), message);
234 }
235
242 [BadMethod("LessOrEqual", "Asserts that the given object is less or equal the other object")]
243 private static void Assert_LessOrEqual([BadParameter(description: "Actual")] decimal a,
244 [BadParameter(description: "Expected")]
245 decimal b,
246 [BadParameter(description: "The Message")]
247 string message)
248 {
249 Assert.That(a, Is.LessThanOrEqualTo(b), message);
250 }
251
258 [BadMethod("Contains", "Asserts that the given collection contains the given object")]
259 private static void Assert_Contains([BadParameter(description: "The Collection to Check")] BadArray collection,
260 [BadParameter(description: "The Object to Check")]
261 BadObject? obj,
262 [BadParameter(description: "The Message")]
263 string message)
264 {
265 Assert.That(collection.InnerArray, Contains.Value(obj!), message);
266 }
267
268
274 [BadMethod("Positive", "Asserts that the given object is positive")]
275 private static void Assert_Positive([BadParameter(description: "The Object to Check")] decimal d,
276 [BadParameter(description: "The Message")] string message)
277 {
278 Assert.That(d, Is.Positive);
279 }
280
286 [BadMethod("Negative", "Asserts that the given object is negative")]
287 private static void Assert_Negative([BadParameter(description: "The Object to Check")] decimal d,
288 [BadParameter(description: "The Message")] string message)
289 {
290 Assert.That(d, Is.Negative);
291 }
292
298 [BadMethod("Zero", "Asserts that the given object is zero")]
299 private static void Assert_Zero([BadParameter(description: "The Object to Check")] decimal d,
300 [BadParameter(description: "The Message")] string message)
301 {
302 Assert.That(d, Is.Zero);
303 }
304
310 [BadMethod("NotZero", "Asserts that the given object is not zero")]
311 private static void Assert_NotZero([BadParameter(description: "The Object to Check")] decimal d,
312 [BadParameter(description: "The Message")] string message)
313 {
314 Assert.That(d, Is.Not.Zero);
315 }
316
321 [BadMethod("Pass", "Passes the test with the given message")]
322 private static void Assert_Pass([BadParameter(description: "The Message")] string message)
323 {
324 Assert.Pass(message);
325 }
326
332 [BadMethod("IsEmpty", "Asserts that the given collection is empty")]
333 private static void Assert_IsEmpty([BadParameter(description: "The Collection to Check")] BadArray collection,
334 [BadParameter(description: "The Message")] string message)
335 {
336 Assert.That(collection.InnerArray, Is.Empty, message);
337 }
338}
static void Assert_NotZero([BadParameter(description:"The Object to Check")] decimal d, [BadParameter(description:"The Message")] string message)
Asserts that the given object is not zero.
static void Assert_AreNotEqual([BadParameter(description:"The Expected Value")] BadObject? expected, [BadParameter(description:"The Actual Value")] BadObject? actual, [BadParameter(description:"The Message")] string message)
Asserts that the given objects are not equal.
static void Assert_AreNotSame([BadParameter(description:"The Expected Value")] BadObject? expected, [BadParameter(description:"The Actual Value")] BadObject? actual, [BadParameter(description:"The Message")] string message)
Asserts that the given objects are not the same.
static void Assert_Negative([BadParameter(description:"The Object to Check")] decimal d, [BadParameter(description:"The Message")] string message)
Asserts that the given object is negative.
static void Assert_Pass([BadParameter(description:"The Message")] string message)
Passes the test with the given message.
static void Assert_Greater([BadParameter(description:"Actual")] decimal a, [BadParameter(description:"Expected")] decimal b, [BadParameter(description:"The Message")] string message)
Asserts that the given object is greater than the other object.
static void Assert_Positive([BadParameter(description:"The Object to Check")] decimal d, [BadParameter(description:"The Message")] string message)
Asserts that the given object is positive.
static void Assert_AreEqual([BadParameter(description:"The Expected Value")] BadObject? expected, [BadParameter(description:"The Actual Value")] BadObject? actual, [BadParameter(description:"The Message")] string message)
Asserts that the given objects are equal.
static void Assert_IsEmpty([BadParameter(description:"The Collection to Check")] BadArray collection, [BadParameter(description:"The Message")] string message)
Asserts that the given collection is empty.
static void Assert_IsTrue([BadParameter(description:"The Condition to check")] BadObject? condition, [BadParameter(description:"The Message")] string message)
Asserts that the given condition is true.
static void Assert_AreSame([BadParameter(description:"The Expected Value")] BadObject? expected, [BadParameter(description:"The Actual Value")] BadObject? actual, [BadParameter(description:"The Message")] string message)
Asserts that the given objects are the same.
static void Assert_IsNull([BadParameter(description:"The Object to check")] BadObject? obj, [BadParameter(description:"The Message")] string message)
Asserts that the given object is null.
static void Assert_IsNotNull([BadParameter(description:"The Object to check")] BadObject? obj, [BadParameter(description:"The Message")] string message)
Asserts that the given object is not null.
static void Assert_Throws(BadExecutionContext ctx, [BadParameter(description:"The Function that is expected to throw")] BadFunction func, [BadParameter(description:"The Message")] string message)
Asserts that the given function throws a BadRuntimeException.
static void Assert_Inconclusive([BadParameter(description:"The Message")] string message)
Marks the test as inconclusive with the given message.
static void Assert_GreaterOrEqual([BadParameter(description:"Actual")] decimal a, [BadParameter(description:"Expected")] decimal b, [BadParameter(description:"The Message")] string message)
Asserts that the given object is greater or equal the other object.
static void Assert_Contains([BadParameter(description:"The Collection to Check")] BadArray collection, [BadParameter(description:"The Object to Check")] BadObject? obj, [BadParameter(description:"The Message")] string message)
Asserts that the given collection contains the given object.
static void Assert_Less([BadParameter(description:"Actual")] decimal a, [BadParameter(description:"Expected")] decimal b, [BadParameter(description:"The Message")] string message)
Asserts that the given object is less than the other object.
static void Assert_IsFalse([BadParameter(description:"The Condition to check")] BadObject? condition, [BadParameter(description:"The Message")] string message)
Asserts that the given condition is false.
static void Assert_Ignore([BadParameter(description:"The Message")] string message)
Ignore the test with the given message.
static void Assert_Zero([BadParameter(description:"The Object to Check")] decimal d, [BadParameter(description:"The Message")] string message)
Asserts that the given object is zero.
static void Assert_LessOrEqual([BadParameter(description:"Actual")] decimal a, [BadParameter(description:"Expected")] decimal b, [BadParameter(description:"The Message")] string message)
Asserts that the given object is less or equal the other object.
static void Assert_Fail([BadParameter(description:"The Message")] string message)
Fails the test with the given message.
The Execution Context. Every execution of a script needs a context the script is running in....
Implements a Dynamic List/Array for the BadScript Language.
Definition BadArray.cs:17
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
Implements a function that can be called from the script.
Implements the Interface for Native Boolean.
Definition IBadBoolean.cs:7
Contains NUnit Extensions and APIs for the BadScript2 Runtime.
Definition BadNUnitApi.cs:7
Contains the Error Objects for the BadScript2 Language.
Contains Runtime Function Objects.
Contains the Native Runtime Objects.
Definition BadBoolean.cs:6
Contains the Runtime Objects.
Definition BadArray.cs:10
Contains the Runtime Implementation.