BadScript 2
Loading...
Searching...
No Matches
BadUnitTestContext.cs
Go to the documentation of this file.
6
7using NUnit.Framework;
8
10
15{
19 private readonly List<BadNUnitTestCase> m_Cases;
20
24 private readonly BadRuntime m_Runtime;
25
29 private readonly List<BadFunction> m_Setup;
30
34 private readonly List<BadFunction> m_Teardown;
35
39 private readonly string m_WorkingDir;
40
49 public BadUnitTestContext(string workingDir,
50 List<BadNUnitTestCase> cases,
51 List<BadFunction> setup,
52 List<BadFunction> teardown,
53 BadRuntime runtime)
54 {
55 m_Cases = cases;
56 m_Setup = setup;
57 m_Teardown = teardown;
58 m_Runtime = runtime;
59 m_WorkingDir = workingDir;
60 }
61
66 private static void Run(IEnumerable<BadObject> enumerable)
67 {
68 foreach (BadObject _ in enumerable)
69 {
70 //Execute
71 }
72 }
73
77 public void Setup()
78 {
79 Run(RunSetup());
80 }
81
85 public void Teardown()
86 {
88 }
89
94 public void Run(BadNUnitTestCase test)
95 {
96 Run(RunTestCase(test));
97 }
98
104 {
105 return m_Cases.ToArray();
106 }
107
113 public IEnumerable<BadObject> RunSetup()
114 {
115 for (int i = m_Setup.Count - 1; i >= 0; i--)
116 {
117 BadFunction function = m_Setup[i];
119
120 foreach (BadObject o in function.Invoke(Array.Empty<BadObject>(), caller))
121 {
122 yield return o;
123 }
124 }
125 }
126
132 public IEnumerable<BadObject> RunTeardown()
133 {
134 for (int i = m_Teardown.Count - 1; i >= 0; i--)
135 {
136 BadFunction function = m_Teardown[i];
138
139 foreach (BadObject o in function.Invoke(Array.Empty<BadObject>(), caller))
140 {
141 yield return o;
142 }
143 }
144 }
145
152 private IEnumerable<BadObject> RunTestCase(BadNUnitTestCase testCase)
153 {
154 TestContext.WriteLine($"Running test '{testCase.TestName}'");
156
158 .Invoke(Array.Empty<BadObject>(), caller)
159 .GetEnumerator()
160 ),
161 testCase.TestName
162 ),
163 true
164 );
165
167 {
169
170 yield return BadObject.Null;
171 }
172 }
173}
Exposes the BadScript Runtime Functionality to Consumers.
Definition BadRuntime.cs:30
BadExecutionContext CreateContext(string workingDirectory)
Creates a new Context with the configured Options.
Implements a Runnable that can return a value.
Implements a Task Object.
Definition BadTask.cs:17
void RunStep()
Runs a single step of the Task Runner.
void AddTask(BadTask task, bool runImmediately=false)
Adds a Task to the Task Runner.
static readonly BadTaskRunner Instance
The Task Runner Instance.
bool IsIdle
Is true if there are no tasks to run.
Represents a BadScript NUnit Test Case.
BadFunction? Function
The Function to Test.
Implements a BadScript NUnit Test Context.
readonly List< BadNUnitTestCase > m_Cases
The Test Cases.
void Run(BadNUnitTestCase test)
Runs a Test Case.
BadUnitTestContext(string workingDir, List< BadNUnitTestCase > cases, List< BadFunction > setup, List< BadFunction > teardown, BadRuntime runtime)
Constructs a new BadUnitTestContext.
IEnumerable< BadObject > RunTeardown()
Runs all Teardown Functions.
static void Run(IEnumerable< BadObject > enumerable)
Runs an enumeration.
readonly string m_WorkingDir
The Working Directory.
readonly List< BadFunction > m_Teardown
The Teardown Functions.
BadNUnitTestCase[] GetTestCases()
Returns all Test Cases.
IEnumerable< BadObject > RunTestCase(BadNUnitTestCase testCase)
Runs a Testcase.
void Teardown()
Runs all Teardown Functions.
readonly List< BadFunction > m_Setup
The Setup Functions.
IEnumerable< BadObject > RunSetup()
Runs all Setup Functions.
readonly BadRuntime m_Runtime
The Runtime.
The Execution Context. Every execution of a script needs a context the script is running in....
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
static readonly BadObject Null
The Null Value for the BadScript Language.
Definition BadObject.cs:28
Implements a function that can be called from the script.
IEnumerable< BadObject > Invoke(BadObject[] args, BadExecutionContext caller)
Invokes the function with the specified arguments.
Contains task/async Extensions and Integrations for the BadScript2 Runtime.
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 Runtime Objects.
Definition BadArray.cs:10
Contains the Runtime Implementation.