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(
26 [BadParameter(description: "The Function that is expected to throw")]
27 BadFunction func,
28 [BadParameter(description: "The Message")]
29 string message)
30 {
31 Assert.Throws<BadRuntimeException>(
32 () =>
33 {
34 foreach (BadObject _ in func.Invoke(Array.Empty<BadObject>(), ctx))
35 {
36 //Do Nothing
37 }
38 },
39 message
40 );
41 }
42
49 [BadMethod("AreEqual", "Asserts that the given objects are equal")]
50 private static void Assert_AreEqual(
51 [BadParameter(description: "The Expected Value")]
52 BadObject? expected,
53 [BadParameter(description: "The Actual Value")]
54 BadObject? actual,
55 [BadParameter(description: "The Message")]
56 string message)
57 {
58 Assert.That(actual, Is.EqualTo(expected), message);
59 }
60
67 [BadMethod("AreNotEqual", "Asserts that the given objects are not equal")]
68 private static void Assert_AreNotEqual(
69 [BadParameter(description: "The Expected Value")]
70 BadObject? expected,
71 [BadParameter(description: "The Actual Value")]
72 BadObject? actual,
73 [BadParameter(description: "The Message")]
74 string message)
75 {
76 Assert.That(actual, Is.Not.EqualTo(expected), message);
77 }
78
85 [BadMethod("AreSame", "Asserts that the given objects are the same")]
86 private static void Assert_AreSame(
87 [BadParameter(description: "The Expected Value")]
88 BadObject? expected,
89 [BadParameter(description: "The Actual Value")]
90 BadObject? actual,
91 [BadParameter(description: "The Message")]
92 string message)
93 {
94 Assert.That(actual, Is.SameAs(expected), message);
95 }
96
103 [BadMethod("AreNotSame", "Asserts that the given objects are not the same")]
104 private static void Assert_AreNotSame(
105 [BadParameter(description: "The Expected Value")]
106 BadObject? expected,
107 [BadParameter(description: "The Actual Value")]
108 BadObject? actual,
109 [BadParameter(description: "The Message")]
110 string message)
111 {
112 Assert.That(actual, Is.Not.SameAs(expected), message);
113 }
114
120 [BadMethod("IsTrue", "Asserts that the given condition is true")]
121 private static void Assert_IsTrue([BadParameter(description: "The Condition to check")] BadObject? condition, [BadParameter(description: "The Message")] string message)
122 {
123 Assert.That(
124 condition is IBadBoolean
125 {
126 Value: true,
127 },
128 Is.True,
129 message
130 );
131 }
132
138 [BadMethod("IsFalse", "Asserts that the given condition is false")]
139 private static void Assert_IsFalse([BadParameter(description: "The Condition to check")] BadObject? condition, [BadParameter(description: "The Message")] string message)
140 {
141 Assert.That(condition is not IBadBoolean b || b.Value, Is.False, message);
142 }
143
144
149 [BadMethod("Fail", "Fails the test with the given message")]
150 private static void Assert_Fail([BadParameter(description: "The Message")] string message)
151 {
152 Assert.Fail(message);
153 }
154
159 [BadMethod("Inconclusive", "Marks the test as inconclusive with the given message")]
160 private static void Assert_Inconclusive([BadParameter(description: "The Message")] string message)
161 {
162 Assert.Inconclusive(message);
163 }
164
169 [BadMethod("Ignore", "Ignore the test with the given message")]
170 private static void Assert_Ignore([BadParameter(description: "The Message")] string message)
171 {
172 Assert.Ignore(message);
173 }
174
175
181 [BadMethod("IsNull", "Asserts that the given object is null")]
182 private static void Assert_IsNull([BadParameter(description: "The Object to check")] BadObject? obj, [BadParameter(description: "The Message")] string message)
183 {
184 Assert.That(obj, Is.Null, message);
185 }
186
192 [BadMethod("IsNotNull", "Asserts that the given object is not null")]
193 private static void Assert_IsNotNull([BadParameter(description: "The Object to check")] BadObject? obj, [BadParameter(description: "The Message")] string message)
194 {
195 Assert.That(obj, Is.Not.Null, message);
196 }
197
204 [BadMethod("Greater", "Asserts that the given object is greater than the other object")]
205 private static void Assert_Greater(
206 [BadParameter(description: "Actual")] decimal a,
207 [BadParameter(description: "Expected")]
208 decimal b,
209 [BadParameter(description: "The Message")]
210 string message)
211 {
212 Assert.That(a, Is.GreaterThan(b), message);
213 }
214
221 [BadMethod("GreaterOrEqual", "Asserts that the given object is greater or equal the other object")]
222 private static void Assert_GreaterOrEqual(
223 [BadParameter(description: "Actual")] decimal a,
224 [BadParameter(description: "Expected")]
225 decimal b,
226 [BadParameter(description: "The Message")]
227 string message)
228 {
229 Assert.That(a, Is.GreaterThanOrEqualTo(b), message);
230 }
231
238 [BadMethod("Less", "Asserts that the given object is less than the other object")]
239 private static void Assert_Less(
240 [BadParameter(description: "Actual")] decimal a,
241 [BadParameter(description: "Expected")]
242 decimal b,
243 [BadParameter(description: "The Message")]
244 string message)
245 {
246 Assert.That(a, Is.LessThan(b), message);
247 }
248
255 [BadMethod("LessOrEqual", "Asserts that the given object is less or equal the other object")]
256 private static void Assert_LessOrEqual(
257 [BadParameter(description: "Actual")] decimal a,
258 [BadParameter(description: "Expected")]
259 decimal b,
260 [BadParameter(description: "The Message")]
261 string message)
262 {
263 Assert.That(a, Is.LessThanOrEqualTo(b), message);
264 }
265
272 [BadMethod("Contains", "Asserts that the given collection contains the given object")]
273 private static void Assert_Contains(
274 [BadParameter(description: "The Collection to Check")]
275 BadArray collection,
276 [BadParameter(description: "The Object to Check")]
277 BadObject? obj,
278 [BadParameter(description: "The Message")]
279 string message)
280 {
281 Assert.That(collection.InnerArray, Contains.Value(obj!), message);
282 }
283
284
290 [BadMethod("Positive", "Asserts that the given object is positive")]
291 private static void Assert_Positive([BadParameter(description: "The Object to Check")] decimal d, [BadParameter(description: "The Message")] string message)
292 {
293 Assert.That(d, Is.Positive);
294 }
295
301 [BadMethod("Negative", "Asserts that the given object is negative")]
302 private static void Assert_Negative([BadParameter(description: "The Object to Check")] decimal d, [BadParameter(description: "The Message")] string message)
303 {
304 Assert.That(d, Is.Negative);
305 }
306
312 [BadMethod("Zero", "Asserts that the given object is zero")]
313 private static void Assert_Zero([BadParameter(description: "The Object to Check")] decimal d, [BadParameter(description: "The Message")] string message)
314 {
315 Assert.That(d, Is.Zero);
316 }
317
323 [BadMethod("NotZero", "Asserts that the given object is not zero")]
324 private static void Assert_NotZero([BadParameter(description: "The Object to Check")] decimal d, [BadParameter(description: "The Message")] string message)
325 {
326 Assert.That(d, Is.Not.Zero);
327 }
328
333 [BadMethod("Pass", "Passes the test with the given message")]
334 private static void Assert_Pass([BadParameter(description: "The Message")] string message)
335 {
336 Assert.Pass(message);
337 }
338
344 [BadMethod("IsEmpty", "Asserts that the given collection is empty")]
345 private static void Assert_IsEmpty([BadParameter(description: "The Collection to Check")] BadArray collection, [BadParameter(description: "The Message")] string message)
346 {
347 Assert.That(collection.InnerArray, Is.Empty, message);
348 }
349}
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.