diff options
author | Wouter Tinus <win.acme.simple@gmail.com> | 2020-02-14 18:58:27 +0100 |
---|---|---|
committer | Wouter Tinus <win.acme.simple@gmail.com> | 2020-02-14 18:58:27 +0100 |
commit | 50e52d5a72c354e09a48894d2877730fdb39239e (patch) | |
tree | f3f39315cd6681961a084ba4d59db9821af04c36 /src | |
parent | 599f8c7850cb7b376ecff73b3ab6a2826b82fb5e (diff) | |
download | letsencrypt-win-simple-50e52d5a72c354e09a48894d2877730fdb39239e.zip letsencrypt-win-simple-50e52d5a72c354e09a48894d2877730fdb39239e.tar.gz letsencrypt-win-simple-50e52d5a72c354e09a48894d2877730fdb39239e.tar.bz2 |
fix build error for test project
Diffstat (limited to 'src')
-rw-r--r-- | src/main.test/Mock/Services/InputService.cs | 26 | ||||
-rw-r--r-- | src/main.test/wacs.test.csproj | 6 |
2 files changed, 21 insertions, 11 deletions
diff --git a/src/main.test/Mock/Services/InputService.cs b/src/main.test/Mock/Services/InputService.cs index 3771cab..58e8d2b 100644 --- a/src/main.test/Mock/Services/InputService.cs +++ b/src/main.test/Mock/Services/InputService.cs @@ -43,25 +43,31 @@ namespace PKISharp.WACS.UnitTests.Mock.Services FirstOrDefault(c => string.Equals(c.Command, input, StringComparison.CurrentCultureIgnoreCase)).Item); } - public Task<TResult> ChooseFromMenu<TResult>(string what, List<Choice<TResult>> choices) - { - var input = GetNextInput(); - return Task. - FromResult(choices. - FirstOrDefault(c => string.Equals(c.Command, input, StringComparison.CurrentCultureIgnoreCase)).Item); - } - public string FormatDate(DateTime date) => ""; public Task<bool> PromptYesNo(string message, bool defaultOption) { var input = GetNextInput(); return Task.FromResult(string.Equals(input, "y", StringComparison.CurrentCultureIgnoreCase)); } - public Task<string> ReadPassword(string what) => Task.FromResult(GetNextInput()); + public Task<string?> ReadPassword(string what) => Task.FromResult(GetNextInput()); public Task<string> RequestString(string what) => Task.FromResult(GetNextInput()); public Task<string> RequestString(string[] what) => Task.FromResult(GetNextInput()); - public void Show(string label, string value = null, bool first = false, int level = 0) { } + public void Show(string? label, string? value = null, bool first = false, int level = 0) { } public Task<bool> Wait(string message = "") => Task.FromResult(true); public Task WritePagedList(IEnumerable<Choice> listItems) => Task.CompletedTask; + public Task<TResult> ChooseFromMenu<TResult>(string what, List<Choice<TResult>> choices, Func<string, Choice<TResult>>? unexpected = null) + { + var input = GetNextInput(); + var choice = choices.FirstOrDefault(c => string.Equals(c.Command, input, StringComparison.CurrentCultureIgnoreCase)); + if (choice == null && unexpected != null) + { + choice = unexpected(input); + } + if (choice != null) + { + return Task.FromResult(choice.Item); + } + throw new Exception(); + } } } diff --git a/src/main.test/wacs.test.csproj b/src/main.test/wacs.test.csproj index f691a52..bbbb8b4 100644 --- a/src/main.test/wacs.test.csproj +++ b/src/main.test/wacs.test.csproj @@ -9,7 +9,11 @@ <RootNamespace>PKISharp.WACS.UnitTests</RootNamespace> </PropertyGroup> - + + <PropertyGroup> + <Nullable>enable</Nullable> + </PropertyGroup> + <ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" /> <PackageReference Include="MSTest.TestAdapter" Version="2.0.0" /> |