Skip to content

Commit

Permalink
make Value-property setter private in options (#1994)
Browse files Browse the repository at this point in the history
  • Loading branch information
fflaten committed Jun 15, 2021
1 parent 2893564 commit bbc4730
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/csharp/Pester/GenericOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Option(string description, T defaultValue, T value)

public T Default { get; private set; }
public string Description { get; private set; }
public T Value { get; set; }
public T Value { get; private set; }

public override string ToString()
{
Expand Down
17 changes: 17 additions & 0 deletions tst/Pester.RSpec.Configuration.ts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,23 @@ i -PassThru:$PassThru {
Verify-Equal $path[0].ToString() -Actual $config.Run.Path.Value[0]
Verify-Equal $path[1].ToString() -Actual $config.Run.Path.Value[1]
}

t "Modifying the private Default property of an option throws" {
$config = [PesterConfiguration]::Default
{ $config.Run.Path.Default = 'invalid' } | Verify-Throw
}

t "Modifying the private Value property of an option throws" {
$config = [PesterConfiguration]::Default
{ $config.Run.Path.Value = 'invalid' } | Verify-Throw
}

t "IsOriginalValue returns false after change even if same as default" {
$config = [PesterConfiguration]::Default
$config.Run.Path.IsOriginalValue() | Verify-True
$config.Run.Path = $config.Run.Path.Default
$config.Run.Path.IsOriginalValue() | Verify-False
}
}

b "Cloning" {
Expand Down

0 comments on commit bbc4730

Please sign in to comment.