Skip to content

Commit

Permalink
Merge pull request #25 from FrendsPlatform/24-powershellrunscript-and…
Browse files Browse the repository at this point in the history
…-powershellruncommand-doesnt-work-in-572

#24 Updated Microsoft.Powershell.SDK dependecy to 7.2.23 to fix issue…
  • Loading branch information
jefim authored Oct 8, 2024
2 parents 8cbe608 + bf82546 commit f553214
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Frends.PowerShell.RunCommand/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.1.0] - 2024-10-08
### Changed
- Updated PowerShell version to 7.2.23

## [1.0.2] - 2022-12-29
### Fixed
- Memory leak fix by unloading assembly context after Task execution.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Host;
using System.Security;
using Frends.PowerShell.RunCommand;
using NUnit.Framework;

namespace Frends.PowerShell.RunScript.Tests;

public class TaskUserInterfaceTests
{
/// <summary>
/// This user interface is a dummy implementation that does not do anything.
/// Ensure that most methods can be called without exceptions.
/// </summary>
[Test]
public void TestTheWholeThing()
{
var taskUserInterface = new TaskUserInterface();
taskUserInterface.Write("Hello, World!");
taskUserInterface.Write(ConsoleColor.Black, ConsoleColor.White, "Hello, World!");
taskUserInterface.WriteLine("Hello, World!");
taskUserInterface.WriteErrorLine("Hello, World!");
taskUserInterface.WriteDebugLine("Hello, World!");
taskUserInterface.WriteProgress(1, new ProgressRecord(1, "Activity", "Status"));
taskUserInterface.WriteVerboseLine("Hello, World!");
taskUserInterface.WriteWarningLine("Hello, World!");
taskUserInterface.ReadLineAsSecureString();

Assert.AreEqual("", taskUserInterface.ReadLine());
Assert.AreEqual(1, taskUserInterface.PromptForChoice("Caption", "Message", new Collection<ChoiceDescription>(), 1));

var answer = taskUserInterface.Prompt("Caption", "Message", new Collection<FieldDescription> { new ("Name") });
Assert.AreEqual(1, answer.Count);

Assert.Throws<NotImplementedException>(() => taskUserInterface.PromptForCredential("Caption", "Message", "UserName", "TargetName"));
Assert.Throws<NotImplementedException>(() => taskUserInterface.PromptForCredential("Caption", "Message", "UserName", "TargetName", PSCredentialTypes.Domain, PSCredentialUIOptions.Default));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AssemblyName>Frends.PowerShell.RunCommand</AssemblyName>
<RootNamespace>Frends.PowerShell.RunCommand</RootNamespace>

<Version>1.0.2</Version>
<Version>1.1.0</Version>
<Authors>Frends</Authors>
<Copyright>Frends</Copyright>
<Company>Frends</Company>
Expand All @@ -28,7 +28,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.1" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.23" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
</ItemGroup>

Expand Down
4 changes: 4 additions & 0 deletions Frends.PowerShell.RunScript/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.1.0] - 2024-10-08
### Changed
- Updated PowerShell version to 7.2.23

[1.0.2] - 2022-12-21
### Changed
- Memory leak fix.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Host;
using System.Security;
using NUnit.Framework;

namespace Frends.PowerShell.RunScript.Tests;

public class TaskUserInterfaceTests
{
/// <summary>
/// This user interface is a dummy implementation that does not do anything.
/// Ensure that most methods can be called without exceptions.
/// </summary>
[Test]
public void TestTheWholeThing()
{
var taskUserInterface = new TaskUserInterface();
taskUserInterface.Write("Hello, World!");
taskUserInterface.Write(ConsoleColor.Black, ConsoleColor.White, "Hello, World!");
taskUserInterface.WriteLine("Hello, World!");
taskUserInterface.WriteErrorLine("Hello, World!");
taskUserInterface.WriteDebugLine("Hello, World!");
taskUserInterface.WriteProgress(1, new ProgressRecord(1, "Activity", "Status"));
taskUserInterface.WriteVerboseLine("Hello, World!");
taskUserInterface.WriteWarningLine("Hello, World!");
taskUserInterface.ReadLineAsSecureString();

Assert.AreEqual("", taskUserInterface.ReadLine());
Assert.AreEqual(1, taskUserInterface.PromptForChoice("Caption", "Message", new Collection<ChoiceDescription>(), 1));

var answer = taskUserInterface.Prompt("Caption", "Message", new Collection<FieldDescription> { new ("Name") });
Assert.AreEqual(1, answer.Count);

Assert.Throws<NotImplementedException>(() => taskUserInterface.PromptForCredential("Caption", "Message", "UserName", "TargetName"));
Assert.Throws<NotImplementedException>(() => taskUserInterface.PromptForCredential("Caption", "Message", "UserName", "TargetName", PSCredentialTypes.Domain, PSCredentialUIOptions.Default));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<IncludeSource>true</IncludeSource>
<AssemblyName>Frends.PowerShell.RunScript</AssemblyName>
<RootNamespace>Frends.PowerShell.RunScript</RootNamespace>
<Version>1.0.2</Version>

<Version>1.1.0</Version>
<Authors>Frends</Authors>
<Copyright>Frends</Copyright>
<Company>Frends</Company>
Expand All @@ -29,7 +29,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.1" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.23" />
</ItemGroup>

</Project>
Expand Down

0 comments on commit f553214

Please sign in to comment.