Skip to content

Commit

Permalink
Adjust conditional params tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JanKrivanek committed Dec 22, 2022
1 parent 1f6ea11 commit 4d82bae
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"type": "parameter",
"datatype": "string",
"description": "parameter A description",
"isEnabled": "A_enabled == true",
"isEnabled": "A_enabled",
"isRequired": true,
"replaces": "placeholderA"
},
"paramB": {
"type": "parameter",
"datatype": "string",
"isEnabled": "B_enabled == true",
"isEnabled": "B_enabled",
"description": "parameter B description",
"replaces": "placeholderB"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// value of paramA: placeholderA
// value of paramB: placeholderB

//#if( A_enabled )
//#if( paramA )
// A is enabled
//#endif

//#if( B_enabled )
//#if( paramB )
// B is enabled
//#endif
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

// value of paramA: valA
// value of paramB: valB
// value of paramA: placeholderA
// value of paramB: placeholderB

// A is enabled

// B is enabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

// value of paramA: true
// value of paramB: true

// A is enabled

// B is enabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

// value of paramA: true
// value of paramB: placeholderB

// A is enabled

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

// value of paramA: true
// value of paramB: placeholderB

// A is enabled

This file was deleted.

30 changes: 5 additions & 25 deletions src/Tests/dotnet-new.Tests/DotnetNewInstantiateTests.Approval.cs
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,11 @@ public Task CanInstantiateTemplate_WithRequiredParams(string parameters, string
}

[Theory]
//[InlineData("TestAssets.TemplateWithConditionalParameters|--paramA|valA|--A_enabled", "A")]
[InlineData("TestAssets.TemplateWithConditionalParameters|--paramA|valA|--paramB|valB|--A_enabled|--B_enabled", "AB")]
[InlineData("TestAssets.TemplateWithConditionalParameters|--paramA|true|--A_enabled", "A_Aenabled")]
[InlineData("TestAssets.TemplateWithConditionalParameters|--paramA|true", "A")]
[InlineData("TestAssets.TemplateWithConditionalParameters|--paramA|true|--paramB|true", "AB")]
[InlineData("TestAssets.TemplateWithConditionalParameters|--paramA|true|--paramB|true|--A_enabled", "AB_Aenabled")]
[InlineData("TestAssets.TemplateWithConditionalParameters|--paramA|true|--paramB|true|--A_enabled|--B_enabled", "AB_ABenabled")]
public Task CanInstantiateTemplate_WithConditionallyEnabledParams(string parameters, string setName)
{
string workingDirectory = CreateTemporaryFolder();
Expand Down Expand Up @@ -730,28 +733,5 @@ public Task CannotInstantiateTemplate_WithoutRequiredParams(string parameters, s
return Verify(commandResult.FormatOutputStreams())
.UseParameters(setName);
}

[Theory]
[InlineData("TestAssets.TemplateWithConditionalParameters|--paramA|valA", "A")]
[InlineData("TestAssets.TemplateWithConditionalParameters|--paramA|valA|--paramB|valB", "AB")]
//[InlineData("TestAssets.TemplateWithConditionalParameters|--paramA|valA|--paramB|valB|--A_enabled", "AB")]
public Task CannotInstantiateTemplate_WithDisabledParams(string parameters, string setName)
{
string workingDirectory = CreateTemporaryFolder();
string homeDirectory = CreateTemporaryFolder();
InstallTestTemplate("TemplateWithConditionalParameters", _log, homeDirectory, workingDirectory);

CommandResult commandResult = new DotnetNewCommand(_log, parameters.Split("|"))
.WithCustomHive(homeDirectory)
.WithWorkingDirectory(workingDirectory)
.Execute();

commandResult
.Should()
.Pass();

return Verify(File.ReadAllText(Path.Combine(workingDirectory, "Test.cs")))
.UseParameters(setName);
}
}
}

0 comments on commit 4d82bae

Please sign in to comment.