-
Notifications
You must be signed in to change notification settings - Fork 367
/
QuitCommandTests.cs
65 lines (51 loc) · 1.63 KB
/
QuitCommandTests.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Threading.Tasks;
using FluentAssertions;
using FluentAssertions.Execution;
using Microsoft.DotNet.Interactive.Commands;
using Microsoft.DotNet.Interactive.Events;
using Microsoft.DotNet.Interactive.Tests.Utility;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.DotNet.Interactive.Tests;
public class QuitCommandTests : LanguageKernelTestBase
{
public QuitCommandTests(ITestOutputHelper output) : base(output)
{
}
[Fact]
public async Task quit_command_fails_when_not_configured()
{
var kernel = CreateKernel();
var quit = new Quit();
await kernel.SendAsync(quit);
using var _ = new AssertionScope();
KernelEvents
.Should().ContainSingle<CommandFailed>()
.Which
.Command
.Should()
.Be(quit);
KernelEvents
.Should().ContainSingle<CommandFailed>()
.Which
.Exception
.Should()
.BeOfType<InvalidOperationException>();
}
[Fact]
public async Task Quit_command_bypasses_work_in_progress()
{
var quitRan = false;
var kernel = CreateKernel().UseQuitCommand(() =>
{
quitRan = true;
return Task.CompletedTask;
});
var workInProgress = kernel.SendAsync(new CancelCommandTests.CancellableCommand());
await kernel.SendAsync(new Quit());
quitRan.Should().BeTrue();
}
}