-
Notifications
You must be signed in to change notification settings - Fork 418
Expand file tree
/
Copy pathSuggestionStoreTests.cs
More file actions
45 lines (40 loc) · 1.85 KB
/
SuggestionStoreTests.cs
File metadata and controls
45 lines (40 loc) · 1.85 KB
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
// 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.CommandLine.Tests.Utility;
using FluentAssertions;
using Xunit.Abstractions;
using static System.Environment;
namespace System.CommandLine.Suggest.Tests
{
public class SuggestionStoreTests : TestsWithTestApps
{
public SuggestionStoreTests(ITestOutputHelper output) : base(output)
{
}
[ReleaseBuildOnlyFact]
public void GetCompletions_obtains_suggestions_successfully()
{
var store = new SuggestionStore();
var completions = store.GetCompletions(EndToEndTestApp.FullName, "[suggest:1] \"a\"", TimeSpan.FromSeconds(1));
completions.Should().Be($"--apple{NewLine}--banana{NewLine}--durian{NewLine}");
}
[ReleaseBuildOnlyFact]
public void GetCompletions_fails_to_obtain_suggestions_because_app_takes_too_long()
{
var store = new SuggestionStore();
var appHangingTimeSpanArgument = TimeSpan.FromMilliseconds(2000).ToString();
var completions = store
.GetCompletions(WaitAndFailTestApp.FullName, appHangingTimeSpanArgument, TimeSpan.FromMilliseconds(1000));
completions.Should().BeEmpty();
}
[ReleaseBuildOnlyFact]
public void GetCompletions_fails_to_obtain_suggestions_because_app_exited_with_nonzero_code()
{
var store = new SuggestionStore();
var appHangingTimeSpanArgument = TimeSpan.FromMilliseconds(0).ToString();
var completions = store
.GetCompletions(WaitAndFailTestApp.FullName, appHangingTimeSpanArgument, TimeSpan.FromMilliseconds(1000));
completions.Should().BeEmpty();
}
}
}