Skip to content

Latest commit

 

History

History
104 lines (80 loc) · 4.88 KB

File metadata and controls

104 lines (80 loc) · 4.88 KB

TestDataGeneration PowerShell Module

PowerShell module providing several cmdlets supporting data and code generation.

Testing

There are 2 different stages of testing. The TestDataGeneration.UnitTests test the underlying components of the nested binary module. The second is the Pester unit tests, included in this project, which tests the functionality within PowerShell.

Pester Unit Tests

Files with the extension .tests.ps1 contain the code for unit tests. Simply invoking the Invoke-Pester command will run these tests.

Note: Tests will only work if they are invoked from the compilation output folder or from the deployed location of the module.

The /.vscode/launch.json provides a launch configuration to allow the Pester tests to be executed from withing VS Code.

Possible Pester Issues

You may see errors such as The BeforeAll command may only be used inside a Describe block. or RuntimeException: '-Be' is not a valid Should operator.. Additionally, you may see a VS code extension error stating Test Discovery failed: A terminating error was received from PowerShell: Pester 5.2.0 or greater is required. This may occur if version 3 or older is installed. To check the version of Pester, execute the following command to make sure you're using at least version 4:

Get-Module -Name 'Pester' -ListAvailable

You can run the following command to install the latest version:

Install-Module -Name Pester -Force -SkipPublisherCheck

Nubmer Parsing

  • NumberStyles.AllowLeadingWhite and NumberStyles.AllowTrailingWhite
  • NumberStyles.AllowLeadingSign and NumberStyles.AllowTrailingSign
    • NumberFormatInfo.PositiveSign
    • NumberFormatInfo.NegativeSign
  • NumberStyles.AllowParentheses - Only one set of parentheses per number.
  • NumberStyles.AllowDecimalPoint
    • NumberFormatInfo.CurrencyDecimalSeparator if NumberStyles.AllowCurrencySymbol; otherwise, NumberFormatInfo.NumberDecimalSeparator
  • NumberStyles.AllowThousands
    • NumberFormatInfo.CurrencyGroupSeparator if NumberStyles.AllowCurrencySymbol; otherwise, NumberFormatInfo.NumberGroupSeparator
  • NumberStyles.AllowExponent - formats following number: [Ee][+-]?\d+ (nnnExx, nnnE+xx and nnnE-xx). Sign for number precedes the number or follows the exponent
  • NumberStyles.AllowCurrencySymbol
    • Uses NumberFormatInfo.CurrencyDecimalSeparator if NumberStyles.AllowDecimalPoint
    • Uses NumberFormatInfo.CurrencyGroupSeparator if NumberStyles.AllowThousands
  • NumberStyles.AllowHexSpecifier - Allows letters a to f and A to F for digits.

TODO

Calculating 'E'

public const double EPSILON = 1.0e-15;

ulong fact = 1;
double e = 2.0;
double e0;
uint n = 2;

do
{
    e0 = e;
    fact *= n++;
    e += 1.0 / fact;
}
while (Math.Abs(e - e0) >= EPSILON);

References

General development reference links