Skip to content

Commit

Permalink
Run dotnet format
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-c-martin committed Jun 13, 2024
1 parent d1a1b93 commit aa4b850
Show file tree
Hide file tree
Showing 134 changed files with 735 additions and 850 deletions.
6 changes: 3 additions & 3 deletions src/Bicep.Cli.IntegrationTests/BuildCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public async Task Build_WithOutDir_ShouldSucceed(string[] args)
var expectedOutputFile = Path.Combine(outputFileDir, "input.json");

File.Exists(expectedOutputFile).Should().BeFalse();
var (output, error, result) = await Bicep(new[] { "build", "--outdir", outputFileDir, bicepPath }.Concat(args).ToArray());
var (output, error, result) = await Bicep(["build", "--outdir", outputFileDir, bicepPath, .. args]);

File.Exists(expectedOutputFile).Should().BeTrue();
output.Should().BeEmpty();
Expand Down Expand Up @@ -477,7 +477,7 @@ public async Task Build_WithOutDir_ShouldSucceed(string[] args)
[DataTestMethod]
public async Task Build_InvalidInputPaths_ShouldProduceExpectedError(string badPath, string[] args, string expectedErrorRegex)
{
var (output, error, result) = await Bicep(new[] { "build" }.Concat(args).Append(badPath).ToArray());
var (output, error, result) = await Bicep(["build", .. args, badPath]);

result.Should().Be(1);
output.Should().BeEmpty();
Expand Down Expand Up @@ -574,7 +574,7 @@ public async Task Build_WithValidBicepConfig_ShouldProduceOutputFileAndExpectedE
var expectedOutputFile = Path.Combine(testOutputPath, "main.json");

File.Exists(expectedOutputFile).Should().BeFalse();
var (output, error, result) = await Bicep(new[] { "build", "--outdir", testOutputPath, inputFile }.Concat(args).ToArray());
var (output, error, result) = await Bicep(["build", "--outdir", testOutputPath, inputFile, .. args]);

File.Exists(expectedOutputFile).Should().BeTrue();
result.Should().Be(0);
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Cli.IntegrationTests/BuildParamsCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ param unusedParam int
var expectedOutputFile = FileHelper.GetResultFilePath(TestContext, "main.json", outputPath);

File.Exists(expectedOutputFile).Should().BeFalse();
var (output, error, result) = await Bicep(new[] { "build-params", inputFile }.Concat(args).ToArray());
var (output, error, result) = await Bicep(["build-params", inputFile, .. args]);

File.Exists(expectedOutputFile).Should().BeTrue();
output.Should().BeEmpty();
Expand Down
6 changes: 3 additions & 3 deletions src/Bicep.Cli.IntegrationTests/DecompileCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ public class DecompileCommandTests : TestBase
}
}";

private readonly string[] DecompilationDisclaimer = new[]
{
private readonly string[] DecompilationDisclaimer =
[
"WARNING: Decompilation is a best-effort process, as there is no guaranteed mapping from ARM JSON to Bicep Template or Bicep Parameters.",
"You may need to fix warnings and errors in the generated bicep/bicepparam file(s), or decompilation may fail entirely if an accurate conversion is not possible.",
"If you would like to report any issues or inaccurate conversions, please see https://github.com/Azure/bicep/issues."
};
];


[TestMethod]
Expand Down
6 changes: 3 additions & 3 deletions src/Bicep.Cli.IntegrationTests/DecompileParamsCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ namespace Bicep.Cli.IntegrationTests
[TestClass]
public class DecompileParamsCommandTests : TestBase
{
private readonly string[] DecompilationDisclaimer = new[]
{
private readonly string[] DecompilationDisclaimer =
[
"WARNING: Decompilation is a best-effort process, as there is no guaranteed mapping from ARM JSON to Bicep Template or Bicep Parameters.",
"You may need to fix warnings and errors in the generated bicep/bicepparam file(s), or decompilation may fail entirely if an accurate conversion is not possible.",
"If you would like to report any issues or inaccurate conversions, please see https://github.com/Azure/bicep/issues."
};
];


[TestMethod]
Expand Down
8 changes: 4 additions & 4 deletions src/Bicep.Cli.IntegrationTests/PublishCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public async Task Publish_AllValidDataSets_ShouldSucceed(string testName, DataSe
requiredArgs.Add("--with-source");
}

string[] args = requiredArgs.ToArray();
string[] args = [.. requiredArgs];

var (output, error, result) = await Bicep(settings, args);
result.Should().Be(0);
Expand Down Expand Up @@ -219,14 +219,14 @@ public async Task Publish_AllValidDataSets_ShouldSucceed(string testName, DataSe

// publish the same content again with --force
requiredArgs.Add("--force");
var (output3, error3, result3) = await Bicep(settings, requiredArgs.ToArray());
var (output3, error3, result3) = await Bicep(settings, [.. requiredArgs]);
result3.Should().Be(0);
output3.Should().BeEmpty();
AssertNoErrors(error3);

// compile to get what the new expected main.json should be
List<string> buildArgs = new() { "build", bicepFilePath, "--outfile", $"{compiledFilePath}.modified" };
var (output4, error4, result4) = await Bicep(settings, buildArgs.ToArray());
var (output4, error4, result4) = await Bicep(settings, [.. buildArgs]);
result4.Should().Be(0);
output4.Should().BeEmpty();
AssertNoErrors(error4);
Expand Down Expand Up @@ -320,7 +320,7 @@ public async Task Publish_ValidArmTemplateFile_WithSource_ShouldFail()
var settings = new InvocationSettings(new(TestContext, RegistryEnabled: true), clientFactory, templateSpecRepositoryFactory);

var args = new List<string> { "publish", compiledFilePath, "--target", $"br:{registryStr}/{repository}:v1", "--with-source" };
var (output, error, result) = await Bicep(settings, args.ToArray());
var (output, error, result) = await Bicep(settings, [.. args]);
result.Should().Be(1);
output.Should().BeEmpty();
error.Should().MatchRegex("Cannot publish with source when the target is an ARM template file.");
Expand Down
6 changes: 3 additions & 3 deletions src/Bicep.Cli.IntegrationTests/PublishProviderCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task Publish_provider_should_succeed()

List<string> requiredArgs = new() { "publish-provider", indexPath, "--target", $"br:{registryStr}/{repository}:{version}" };

string[] args = requiredArgs.ToArray();
string[] args = [.. requiredArgs];

var result = await Bicep(settings, args);
result.Should().Succeed().And.NotHaveStdout();
Expand All @@ -62,13 +62,13 @@ public async Task Publish_provider_should_succeed()
saBodyType.Properties.Keys.Should().Contain("name", "location", "properties", "sku", "tags");

// publishing without --force should fail
result = await Bicep(settings, requiredArgs.ToArray());
result = await Bicep(settings, [.. requiredArgs]);
result.Should().Fail().And.HaveStderrMatch("*The Provider \"*\" already exists. Use --force to overwrite the existing provider.*");

// test with force
requiredArgs.Add("--force");

var result2 = await Bicep(settings, requiredArgs.ToArray());
var result2 = await Bicep(settings, [.. requiredArgs]);
result2.Should().Succeed().And.NotHaveStdout();

// verify the provider was published
Expand Down
48 changes: 24 additions & 24 deletions src/Bicep.Cli.UnitTests/ArgumentParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ public class ArgumentParserTests
[TestMethod]
public void Empty_parameters_should_return_null()
{
var arguments = ArgumentParser.TryParse(Array.Empty<string>(), IO, FileSystem);
var arguments = ArgumentParser.TryParse([], IO, FileSystem);
arguments.Should().BeNull();
}

[TestMethod]
public void Wrong_command_should_return_null()
{
var arguments = ArgumentParser.TryParse(new[] { "wrong" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["wrong"], IO, FileSystem);
arguments.Should().BeNull();
}

Expand Down Expand Up @@ -74,7 +74,7 @@ public void Invalid_args_trigger_validation_exceptions(string[] parameters, stri
[TestMethod]
public void BuildOneFile_ShouldReturnOneFile()
{
var arguments = ArgumentParser.TryParse(new[] { "build", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["build", "file1"], IO, FileSystem);
var buildArguments = (BuildArguments?)arguments;

// using classic assert so R# understands the value is not null
Expand All @@ -89,7 +89,7 @@ public void BuildOneFile_ShouldReturnOneFile()
[TestMethod]
public void BuildOneFileStdOut_ShouldReturnOneFileAndStdout()
{
var arguments = ArgumentParser.TryParse(new[] { "build", "--stdout", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["build", "--stdout", "file1"], IO, FileSystem);
var buildArguments = (BuildArguments?)arguments;

// using classic assert so R# understands the value is not null
Expand All @@ -104,7 +104,7 @@ public void BuildOneFileStdOut_ShouldReturnOneFileAndStdout()
[TestMethod]
public void BuildOneFileStdOut_and_no_restore_ShouldReturnOneFileAndStdout()
{
var arguments = ArgumentParser.TryParse(new[] { "build", "--stdout", "--no-restore", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["build", "--stdout", "--no-restore", "file1"], IO, FileSystem);
var buildArguments = (BuildArguments?)arguments;

// using classic assert so R# understands the value is not null
Expand All @@ -119,7 +119,7 @@ public void BuildOneFileStdOut_and_no_restore_ShouldReturnOneFileAndStdout()
[TestMethod]
public void BuildOneFileStdOutAllCaps_ShouldReturnOneFileAndStdout()
{
var arguments = ArgumentParser.TryParse(new[] { "build", "--STDOUT", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["build", "--STDOUT", "file1"], IO, FileSystem);
var buildArguments = (BuildArguments?)arguments;

// using classic assert so R# understands the value is not null
Expand All @@ -135,7 +135,7 @@ public void BuildOneFileStdOutAllCaps_ShouldReturnOneFileAndStdout()
public void Build_with_outputdir_parameter_should_parse_correctly()
{
// Use relative . to ensure directory exists else the parser will throw.
var arguments = ArgumentParser.TryParse(new[] { "build", "--outdir", ".", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["build", "--outdir", ".", "file1"], IO, FileSystem);
var buildArguments = (BuildArguments?)arguments;

// using classic assert so R# understands the value is not null
Expand All @@ -151,7 +151,7 @@ public void Build_with_outputdir_parameter_should_parse_correctly()
[TestMethod]
public void Build_with_outputfile_parameter_should_parse_correctly()
{
var arguments = ArgumentParser.TryParse(new[] { "build", "--outfile", "jsonFile", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["build", "--outfile", "jsonFile", "file1"], IO, FileSystem);
var buildArguments = (BuildArguments?)arguments;

// using classic assert so R# understands the value is not null
Expand All @@ -166,7 +166,7 @@ public void Build_with_outputfile_parameter_should_parse_correctly()
[TestMethod]
public void Build_with_outputfile_and_no_restore_parameter_should_parse_correctly()
{
var arguments = ArgumentParser.TryParse(new[] { "build", "--outfile", "jsonFile", "file1", "--no-restore" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["build", "--outfile", "jsonFile", "file1", "--no-restore"], IO, FileSystem);
var buildArguments = (BuildArguments?)arguments;

// using classic assert so R# understands the value is not null
Expand All @@ -181,7 +181,7 @@ public void Build_with_outputfile_and_no_restore_parameter_should_parse_correctl
[TestMethod]
public void License_argument_should_return_appropriate_RootArguments_instance()
{
var arguments = ArgumentParser.TryParse(new[] { "--license" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["--license"], IO, FileSystem);

arguments.Should().BeOfType<RootArguments>();
if (arguments is RootArguments rootArguments)
Expand All @@ -196,7 +196,7 @@ public void License_argument_should_return_appropriate_RootArguments_instance()
[TestMethod]
public void Third_party_notices_argument_should_return_appropriate_RootArguments_instance()
{
var arguments = ArgumentParser.TryParse(new[] { "--third-party-notices" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["--third-party-notices"], IO, FileSystem);

arguments.Should().BeOfType<RootArguments>();
if (arguments is RootArguments rootArguments)
Expand All @@ -211,7 +211,7 @@ public void Third_party_notices_argument_should_return_appropriate_RootArguments
[TestMethod]
public void Version_argument_should_return_VersionArguments_instance()
{
var arguments = ArgumentParser.TryParse(new[] { "--version" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["--version"], IO, FileSystem);

arguments.Should().BeOfType<RootArguments>();
if (arguments is RootArguments rootArguments)
Expand All @@ -226,7 +226,7 @@ public void Version_argument_should_return_VersionArguments_instance()
[TestMethod]
public void Help_argument_should_return_HelpArguments_instance()
{
var arguments = ArgumentParser.TryParse(new[] { "--help" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["--help"], IO, FileSystem);

arguments.Should().BeOfType<RootArguments>();
if (arguments is RootArguments rootArguments)
Expand All @@ -241,7 +241,7 @@ public void Help_argument_should_return_HelpArguments_instance()
[TestMethod]
public void Version_argument_should_return_VersionShortArguments_instance()
{
var arguments = ArgumentParser.TryParse(new[] { "-v" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["-v"], IO, FileSystem);

arguments.Should().BeOfType<RootArguments>();
if (arguments is RootArguments rootArguments)
Expand All @@ -256,7 +256,7 @@ public void Version_argument_should_return_VersionShortArguments_instance()
[TestMethod]
public void Help_argument_should_return_HelpShortArguments_instance()
{
var arguments = ArgumentParser.TryParse(new[] { "-h" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["-h"], IO, FileSystem);

arguments.Should().BeOfType<RootArguments>();
if (arguments is RootArguments rootArguments)
Expand All @@ -271,7 +271,7 @@ public void Help_argument_should_return_HelpShortArguments_instance()
[TestMethod]
public void DecompileOneFile_ShouldReturnOneFile()
{
var arguments = ArgumentParser.TryParse(new[] { "decompile", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["decompile", "file1"], IO, FileSystem);
var bulidOrDecompileArguments = (DecompileArguments?)arguments;

// using classic assert so R# understands the value is not null
Expand All @@ -285,7 +285,7 @@ public void DecompileOneFile_ShouldReturnOneFile()
[TestMethod]
public void DecompileOneFileStdOut_ShouldReturnOneFileAndStdout()
{
var arguments = ArgumentParser.TryParse(new[] { "decompile", "--stdout", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["decompile", "--stdout", "file1"], IO, FileSystem);
var bulidOrDecompileArguments = (DecompileArguments?)arguments;

// using classic assert so R# understands the value is not null
Expand All @@ -299,7 +299,7 @@ public void DecompileOneFileStdOut_ShouldReturnOneFileAndStdout()
[TestMethod]
public void DecompileOneFileStdOutAllCaps_ShouldReturnOneFileAndStdout()
{
var arguments = ArgumentParser.TryParse(new[] { "decompile", "--STDOUT", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["decompile", "--STDOUT", "file1"], IO, FileSystem);
var bulidOrDecompileArguments = (DecompileArguments?)arguments;

// using classic assert so R# understands the value is not null
Expand All @@ -314,7 +314,7 @@ public void DecompileOneFileStdOutAllCaps_ShouldReturnOneFileAndStdout()
public void Decompile_with_outputdir_parameter_should_parse_correctly()
{
// Use relative . to ensure directory exists else the parser will throw.
var arguments = ArgumentParser.TryParse(new[] { "decompile", "--outdir", ".", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["decompile", "--outdir", ".", "file1"], IO, FileSystem);
var bulidOrDecompileArguments = (DecompileArguments?)arguments;

// using classic assert so R# understands the value is not null
Expand All @@ -328,7 +328,7 @@ public void Decompile_with_outputdir_parameter_should_parse_correctly()
[TestMethod]
public void Decompile_with_outputfile_parameter_should_parse_correctly()
{
var arguments = ArgumentParser.TryParse(new[] { "decompile", "--outfile", "jsonFile", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["decompile", "--outfile", "jsonFile", "file1"], IO, FileSystem);
var bulidOrDecompileArguments = (DecompileArguments?)arguments;

// using classic assert so R# understands the value is not null
Expand All @@ -342,7 +342,7 @@ public void Decompile_with_outputfile_parameter_should_parse_correctly()
[TestMethod]
public void Publish_should_parse_correctly()
{
var arguments = ArgumentParser.TryParse(new[] { "publish", "file1", "--target", "target1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["publish", "file1", "--target", "target1"], IO, FileSystem);
arguments.Should().BeOfType<PublishArguments>();
var typed = (PublishArguments)arguments!;

Expand All @@ -354,7 +354,7 @@ public void Publish_should_parse_correctly()
[TestMethod]
public void Publish_with_no_restore_should_parse_correctly()
{
var arguments = ArgumentParser.TryParse(new[] { "publish", "file1", "--target", "target1", "--no-restore" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["publish", "file1", "--target", "target1", "--no-restore"], IO, FileSystem);
arguments.Should().BeOfType<PublishArguments>();
var typed = (PublishArguments)arguments!;

Expand All @@ -366,7 +366,7 @@ public void Publish_with_no_restore_should_parse_correctly()
[TestMethod]
public void Restore__with_no_force_should_parse_correctly()
{
var arguments = ArgumentParser.TryParse(new[] { "restore", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["restore", "file1"], IO, FileSystem);
arguments.Should().BeOfType<RestoreArguments>();
var typed = (RestoreArguments)arguments!;

Expand All @@ -377,7 +377,7 @@ public void Restore__with_no_force_should_parse_correctly()
[TestMethod]
public void Restore_with_force_should_parse_correctly()
{
var arguments = ArgumentParser.TryParse(new[] { "restore", "--force", "file1" }, IO, FileSystem);
var arguments = ArgumentParser.TryParse(["restore", "--force", "file1"], IO, FileSystem);
arguments.Should().BeOfType<RestoreArguments>();
var typed = (RestoreArguments)arguments!;

Expand Down
Loading

0 comments on commit aa4b850

Please sign in to comment.