-
-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to skip run and return the result object right after discovery.
- Loading branch information
Showing
24 changed files
with
1,718 additions
and
1,299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// those types implement Pester configuration in a way that allows it to show information about each item | ||
// in the powershell console without making it difficult to use. there are two tricks being used: | ||
// - constructor taking IDictionary (most likely a hashtable) that will populate the object, | ||
// this allows the object to be constructed from a hashtable simply by casting to the type | ||
// both implicitly and explicitly, so the user does not have to care about what types are used | ||
// but will still get the benefit of the data annotation in the object. Usage is like this: | ||
// `$config.Debug = @{ WriteDebugMessages = $true; WriteDebugMessagesFrom = "Mock*" }`, which | ||
// will populate the config with the given values while keeping all other values to the default. | ||
// - to be able to assign values like this: `$config.Should.ErrorAction = 'Continue'` but still | ||
// get the documentation when accessing the property, we use implicit casting to get an instance of | ||
// StringOption, and then populate it from the option object that is already assigned to the property | ||
// | ||
// lastly most of the types go to Pester namespace to keep them from the global namespace because they are | ||
// simple to use by implicit casting, with the only exception of PesterConfiguration because that is helpful | ||
// to have in "type accelerator" form, but without the hassle of actually adding it as a type accelerator | ||
// that way you can easily do `[PesterConfiguration]::Default` and then inspect it, or cast a hashtable to it | ||
|
||
namespace Pester | ||
{ | ||
public class BoolOption : Option<bool> | ||
{ | ||
public BoolOption(BoolOption option, bool value) : base(option, value) | ||
{ | ||
|
||
} | ||
|
||
public BoolOption(string description, bool defaultValue) : base(description, defaultValue, defaultValue) | ||
{ | ||
|
||
} | ||
|
||
public BoolOption(string description, bool defaultValue, bool value) : base(description, defaultValue, value) | ||
{ | ||
|
||
} | ||
|
||
public static implicit operator BoolOption(bool value) | ||
{ | ||
return new BoolOption(string.Empty, value, value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Linq; | ||
|
||
// those types implement Pester configuration in a way that allows it to show information about each item | ||
// in the powershell console without making it difficult to use. there are two tricks being used: | ||
// - constructor taking IDictionary (most likely a hashtable) that will populate the object, | ||
// this allows the object to be constructed from a hashtable simply by casting to the type | ||
// both implicitly and explicitly, so the user does not have to care about what types are used | ||
// but will still get the benefit of the data annotation in the object. Usage is like this: | ||
// `$config.Debug = @{ WriteDebugMessages = $true; WriteDebugMessagesFrom = "Mock*" }`, which | ||
// will populate the config with the given values while keeping all other values to the default. | ||
// - to be able to assign values like this: `$config.Should.ErrorAction = 'Continue'` but still | ||
// get the documentation when accessing the property, we use implicit casting to get an instance of | ||
// StringOption, and then populate it from the option object that is already assigned to the property | ||
// | ||
// lastly most of the types go to Pester namespace to keep them from the global namespace because they are | ||
// simple to use by implicit casting, with the only exception of PesterConfiguration because that is helpful | ||
// to have in "type accelerator" form, but without the hassle of actually adding it as a type accelerator | ||
// that way you can easily do `[PesterConfiguration]::Default` and then inspect it, or cast a hashtable to it | ||
|
||
namespace Pester | ||
{ | ||
internal static class Cloner | ||
{ | ||
public static T ShallowClone<T>(T obj) where T : new() | ||
{ | ||
var cfg = new T(); | ||
var properties = typeof(T).GetProperties().ToList(); | ||
|
||
foreach (var p in properties.Where(p => p.CanRead && p.CanWrite)) | ||
{ | ||
var value = p.GetValue(obj); | ||
p.SetValue(cfg, value); | ||
} | ||
|
||
return cfg; | ||
} | ||
} | ||
} |
Oops, something went wrong.