public void FormattingScriptCommandsReplacesVariablesWithTheRightMSBuildProperties( string variable, string msbuildReplacement) { var scriptMigrationRule = new MigrateScriptsRule(); scriptMigrationRule.ReplaceScriptVariables($"%{variable}%").Should().Be(msbuildReplacement); }
public void Formatting_script_commands_replaces_variables_with_the_right_msbuild_properties( string variable, string msbuildReplacement) { var scriptMigrationRule = new MigrateScriptsRule(); scriptMigrationRule.ReplaceScriptVariables($"%{variable}%").Should().Be(msbuildReplacement); }
public void FormattingScriptCommandsThrowsWhenVariableIsUnsupported(string unsupportedVariable) { var scriptMigrationRule = new MigrateScriptsRule(); Action formatScriptAction = () => scriptMigrationRule.ReplaceScriptVariables($"%{unsupportedVariable}%"); formatScriptAction.ShouldThrow <Exception>() .Where(exc => exc.Message.Contains("is currently an unsupported script variable for project migration")); }
public void Migrated_ScriptSet_has_ScriptExtension_added_to_script_command(string scriptCommandline, string expectedOutputCommand) { var scriptMigrationRule = new MigrateScriptsRule(); var formattedCommand = scriptMigrationRule.AddScriptExtensionPropertyToCommandLine(scriptCommandline, "MigratedScriptExtension_1"); formattedCommand.Should().Be(expectedOutputCommand); }
public void Migrating_post_scripts_populates_AfterTargets_with_appropriate_target(string scriptName, string targetName) { var scriptMigrationRule = new MigrateScriptsRule(); ProjectRootElement mockProj = ProjectRootElement.Create(); var commands = new[] { "fakecommand" }; var target = scriptMigrationRule.MigrateScriptSet(mockProj, mockProj.AddPropertyGroup(), commands, scriptName); target.AfterTargets.Should().Be(targetName); }
public void Migrated_ScriptSet_has_dotSlash_prepended_when_command_is_not_rooted(string scriptCommandline, string expectedOutputCommandPrefix) { var scriptMigrationRule = new MigrateScriptsRule(); var formattedCommand = scriptMigrationRule.FormatScriptCommand(scriptCommandline, "MigratedScriptExtension_1"); formattedCommand.Should().StartWith(expectedOutputCommandPrefix); }
public void Migrating_scripts_creates_target_with_IsCrossTargettingBuild_not_equal_true_Condition() { var scriptMigrationRule = new MigrateScriptsRule(); ProjectRootElement mockProj = ProjectRootElement.Create(); var commands = new[] { "compile:FullTargetFramework", "compile:Configuration" }; var target = scriptMigrationRule.MigrateScriptSet(mockProj, mockProj.AddPropertyGroup(), commands, "prepublish"); target.Condition.Should().Be(" '$(IsCrossTargetingBuild)' != 'true' "); }
public void Migrating_scripts_throws_on_invalid_ScriptSet() { var scriptMigrationRule = new MigrateScriptsRule(); ProjectRootElement mockProj = ProjectRootElement.Create(); var commands = new string[] { "fakecommand" }; Action action = () => scriptMigrationRule.MigrateScriptSet(mockProj, mockProj.AddPropertyGroup(), commands, "invalidScriptSet"); action.ShouldThrow <MigrationException>() .WithMessage("MIGRATE1019::Unsupported Script Event Hook: invalidScriptSet is an unsupported script event hook for project migration"); }
public void MigratingScriptsWithMultiTFMCreatesTargetWithIsCrossTargettingBuildNotEqualTrueCondition() { var scriptMigrationRule = new MigrateScriptsRule(); ProjectRootElement mockProj = ProjectRootElement.Create(); var commands = new[] { "compile:FullTargetFramework", "compile:Configuration" }; var target = scriptMigrationRule.MigrateScriptSet( mockProj, commands, "prepublish", IsMultiTFM); target.Condition.Should().Be(" '$(IsCrossTargetingBuild)' != 'true' "); }
public void MigratingScriptsWithSingleTFMDoesNotCreateTargetWithIsCrossTargettingBuild() { var scriptMigrationRule = new MigrateScriptsRule(); ProjectRootElement mockProj = ProjectRootElement.Create(); var commands = new[] { "compile:FullTargetFramework", "compile:Configuration" }; var target = scriptMigrationRule.MigrateScriptSet( mockProj, commands, "prepublish", false); target.Condition.Should().BeEmpty(); }
public void MigratingPreScriptsPopulatesBeforeTargetsWithAppropriateTarget( string scriptName, string targetName) { var scriptMigrationRule = new MigrateScriptsRule(); ProjectRootElement mockProj = ProjectRootElement.Create(); var commands = new string[] { "fakecommand" }; var target = scriptMigrationRule.MigrateScriptSet( mockProj, mockProj.AddPropertyGroup(), commands, scriptName); target.BeforeTargets.Should().Be(targetName); }
public void MigratingPostScriptsPopulatesAfterTargetsWithAppropriateTarget( string scriptName, string targetName) { var scriptMigrationRule = new MigrateScriptsRule(); ProjectRootElement mockProj = ProjectRootElement.Create(); var commands = new[] { "fakecommand" }; var target = scriptMigrationRule.MigrateScriptSet( mockProj, commands, scriptName, IsMultiTFM); target.AfterTargets.Should().Be(targetName); }
public void PublishIISCommandDoesNotGetMigratedBecauseItIsNowInTheWebSDK() { var scriptMigrationRule = new MigrateScriptsRule(); ProjectRootElement mockProj = ProjectRootElement.Create(); var commands = new[] { "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" }; var target = scriptMigrationRule.MigrateScriptSet( mockProj, mockProj.AddPropertyGroup(), commands, "postpublish"); target.Tasks.Should().BeEmpty(); }
public void Migrated_ScriptSet_has_Exec_and_replaces_variables(string scriptName) { var scriptMigrationRule = new MigrateScriptsRule(); ProjectRootElement mockProj = ProjectRootElement.Create(); var commands = new[] { "%compile:FullTargetFramework%", "%compile:Configuration%" }; var target = scriptMigrationRule.MigrateScriptSet(mockProj, mockProj.AddPropertyGroup(), commands, scriptName); target.Tasks.Count().Should().Be(commands.Length); foreach (var task in target.Tasks) { var taskCommand = task.GetParameter("Command"); var commandIndex = Array.IndexOf(commands, taskCommand); commandIndex.Should().Be(-1, "Expected command array elements to be replaced by appropriate msbuild properties"); } }
public void MigratingScriptsReplacesRazorPrecompileWithProperty() { var scriptMigrationRule = new MigrateScriptsRule(); ProjectRootElement mockProj = ProjectRootElement.Create(); ProjectPropertyGroupElement commonPropertyGroup = mockProj.AddPropertyGroup(); var commands = new string[] { "dotnet razor-precompile --configuration %publish:Configuration% --framework %publish:TargetFramework% --output-path %publish:OutputPath% %publish:ProjectPath%" }; var target = scriptMigrationRule.MigrateScriptSet( mockProj, commonPropertyGroup, commands, "postpublish", IsMultiTFM); target.Tasks.Should().BeEmpty(); commonPropertyGroup.Properties.Count().Should().Be(1); var propertyElement = commonPropertyGroup.Properties.First(); propertyElement.Name.Should().Be("MvcRazorCompileOnPublish"); propertyElement.Value.Should().Be("true"); }
public void FormattingScriptCommandsReplacesUnknownVariablesWithMSBuildPropertyForEnvironmentVariableSupport() { var scriptMigrationRule = new MigrateScriptsRule(); scriptMigrationRule.ReplaceScriptVariables($"%UnknownVariable%").Should().Be("$(UnknownVariable)"); }
public void Formatting_script_commands_replaces_unknown_variables_with_MSBuild_Property_for_environment_variable_support() { var scriptMigrationRule = new MigrateScriptsRule(); scriptMigrationRule.ReplaceScriptVariables($"%UnknownVariable%").Should().Be("$(UnknownVariable)"); }