Add some basic option mapper tests to catch source gen errors

This commit is contained in:
Caelan Sayler
2024-03-28 11:17:36 +00:00
parent 3694c31bb3
commit ed00aaefe3

View File

@@ -0,0 +1,36 @@
using System.CommandLine;
using Velopack.Deployment;
using Velopack.Vpk;
using Velopack.Vpk.Commands.Deployment;
namespace Velopack.CommandLine.Tests;
public class OptionMapperTests
{
[Fact]
public void MapRid()
{
Assert.True(OptionMapper.Map<RID>("win-x64") == RID.Parse("win-x64"));
}
[Fact]
public void MapDirectory()
{
Assert.Equal("C:\\hello", OptionMapper.Map<DirectoryInfo>("C:\\hello").FullName);
}
[Fact]
public void MapCommand()
{
AzureUploadCommand command = new();
string cli = $"--account \"account-name\" --key \"shhhh\" --endpoint \"https://endpoint\" --container \"mycontainer\"";
ParseResult parseResult = command.ParseAndApply(cli);
var options = OptionMapper.Map<AzureUploadOptions>(command);
Assert.Empty(parseResult.Errors);
Assert.Equal("account-name", options.Account);
Assert.Equal("shhhh", options.Key);
Assert.Equal("https://endpoint/", options.Endpoint);
Assert.Equal("mycontainer", options.Container);
}
}