|
8 | 8 |
|
9 | 9 | namespace NotebookUnit
|
10 | 10 | {
|
11 |
| - public class RunTestsMagicCommand : IKernelExtension |
12 |
| - { |
13 |
| - public async Task OnLoadAsync(Kernel kernel) |
14 |
| - { |
| 11 | + public class RunTestsMagicCommand : IKernelExtension |
| 12 | + { |
| 13 | + public async Task OnLoadAsync(Kernel kernel) |
| 14 | + { |
15 | 15 |
|
16 |
| - var testCommand = new Command("#!test", "Run the tests in this notebook") |
17 |
| - { |
18 |
| - new Option<Action[]>(new string[] {"-t", "--tests" }, () => new Action[] { }, "Specify tests to run") |
19 |
| - }; |
| 16 | + var testCommand = new Command("#!test", "Run the tests in this notebook") |
| 17 | + { |
| 18 | + new Option<Action[]>(new string[] {"-t", "--tests" }, () => new Action[] { }, "Specify tests to run") |
| 19 | + }; |
20 | 20 |
|
21 |
| - testCommand.Handler = |
22 |
| - CommandHandler.Create(async (Action[] tests, KernelInvocationContext context) => |
23 |
| - RunTests(tests, context)); |
| 21 | + testCommand.Handler = |
| 22 | + CommandHandler.Create(async (Action[] tests, KernelInvocationContext context) => |
| 23 | + RunTests(tests, context)); |
24 | 24 |
|
25 |
| - kernel.AddDirective(testCommand); |
| 25 | + kernel.AddDirective(testCommand); |
26 | 26 |
|
27 |
| - if (KernelInvocationContext.Current is { } context) |
28 |
| - { |
29 |
| - await context.DisplayAsync($"`{nameof(RunTestsMagicCommand)}` is loaded. It enables testing in notebooks", "text/markdown"); |
30 |
| - } |
| 27 | + if (KernelInvocationContext.Current is { } context) |
| 28 | + { |
| 29 | + await context.DisplayAsync($"`{nameof(RunTestsMagicCommand)}` is loaded. It enables testing in notebooks", "text/markdown"); |
| 30 | + } |
31 | 31 |
|
32 |
| - } |
| 32 | + } |
33 | 33 |
|
34 | 34 | private object RunTests(Action[] tests, KernelInvocationContext context)
|
35 | 35 | {
|
36 | 36 |
|
37 |
| - if (tests == null || tests.Length == 0) { |
38 |
| - context.Fail(message: "No tests"); |
39 |
| - return null; |
| 37 | + if (tests == null || tests.Length == 0) |
| 38 | + { |
| 39 | + context.Fail(message: "No tests"); |
| 40 | + return null; |
40 | 41 | }
|
41 | 42 |
|
42 |
| - context.Publish(new DisplayedValueProduced("Tests to be run", context.Command, new[] { |
43 |
| - new FormattedValue(PlainTextFormatter.MimeType, "Tests will be run") |
44 |
| - })); |
| 43 | + context.Publish(new DisplayedValueProduced("Tests to be run", context.Command, new[] { |
| 44 | + new FormattedValue(PlainTextFormatter.MimeType, "Tests will be run") |
| 45 | + })); |
45 | 46 |
|
46 |
| - return new object(); |
| 47 | + return new object(); |
47 | 48 |
|
48 | 49 | }
|
49 | 50 |
|
|
0 commit comments