Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Added tests for hashtabletoPSCustomObjectConversion, OutErrorVairable…#2160

Merged
vors merged 14 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
bingbing8:Add-Tests-to-Language-Part-4bingbing8/PowerShell:Add-Tests-to-Language-Part-4Copy head branch name to clipboard
Sep 13, 2016
Merged

Added tests for hashtabletoPSCustomObjectConversion, OutErrorVairable…#2160
vors merged 14 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
bingbing8:Add-Tests-to-Language-Part-4bingbing8/PowerShell:Add-Tests-to-Language-Part-4Copy head branch name to clipboard

Conversation

@bingbing8

Copy link
Copy Markdown
Contributor

Added tests for hashtabletoPSCustomObjectConversion, OutErrorVairable. Please review.

@msftclas

msftclas commented Sep 1, 2016

Copy link
Copy Markdown

Hi @bingbing8, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Yanbing Wang). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

@vors vors closed this Sep 2, 2016
@vors vors reopened this Sep 2, 2016
@msftclas

msftclas commented Sep 2, 2016

Copy link
Copy Markdown

Hi @bingbing8, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Yanbing Wang). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

@JamesWTruher

JamesWTruher commented Sep 2, 2016

Copy link
Copy Markdown
Collaborator

��D�e�s�c�r�i�b�e� �"�T�e�s�t�s� �f�o�r� �h�a�s�h�t�a�b�l�e� �t�o� �P�S�C�u�s�t�o�m�O�b�j�e�c�t� �c�o�n�v�e�r�s�i�o�n�"� �-�T�a�g�s� �"�C�I�"� �{�

this file looks to be the wrong encoding - can you be sure that the BOM is not present and that the file is UTF8 (or ascii) - it's really hard to read


Refers to: test/powershell/Language/Scripting/HashtableToPSCustomObjectConversion.Tests.ps1:1 in 31f22c6. [](commit_id = 31f22c6, deletion_comment = False)

@JamesWTruher

Copy link
Copy Markdown
Collaborator

� � � � � � � � �I�t� �'�$�a� �t�y�p�e�'� �{� �$�a� �-�i�s� �[�S�y�s�t�e�m�.�M�a�n�a�g�e�m�e�n�t�.�A�u�t�o�m�a�t�i�o�n�.�P�S�O�b�j�e�c�t�]� �|� �S�h�o�u�l�d� �B�e� �$�t�r�u�e� �}� � � � � � � � �

this can be

it '$a type' { $a | should BeOfType "System.Management.automation.psobject" }

Refers to: test/powershell/Language/Scripting/HashtableToPSCustomObjectConversion.Tests.ps1:15 in 31f22c6. [](commit_id = 31f22c6, deletion_comment = False)

@JamesWTruher

Copy link
Copy Markdown
Collaborator

I don't think we really need a new type here - wouldn't this be ok?

describe "good description here" {
    it "good test name here" {
        try {
            new-object System.Management.Automation.MetadataException -property @{ Source = "foobar"; aa = 1 }
            throw "OK"
        }
        catch {
            $_.Exception | Should BeOfType "InvalidOperationException"
            $_.Exception.Message | Should Match "aa"
            $_.FullyQualifiedErrorId | should be "InvalidOperationException,Microsoft.PowerShell.Commands.NewObjectCommand"
        }
    }
}

Refers to: test/powershell/Language/Scripting/HashtableToPSCustomObjectConversion.Tests.ps1:66 in 31f22c6. [](commit_id = 31f22c6, deletion_comment = False)

}

Context 'Updating OutVariable Case 1: pipe string' {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't going to do anything because they're not in it blocks, also these really look like they could all be done via test cases


$testcases = @{ Title = "Updating OutVariable Case 1: pipe string"; command = "get-foo1"; OutVariable = "a"; Expected = "foo" },
        @{ Title = 'Updating OutVariable Case 2: $pscmdlet.writeobject'; command = "get-foo1"; OutVariable = "a"; Expected = "foo" }

Describe Tests {
    BeforeAll {

        function get-foo1
        {
            [CmdletBinding()]
            param()

            "foo"
        }

        function get-foo2
        {
            [CmdletBinding()]
            param()

            $pscmdlet.writeobject("foo")
        }

        function get-bar 
        {
            [CmdletBinding()]
            param()

            "bar"
            get-foo1 -outVariable global:a
        }

    }
    It "<Title>" -TestCases $testcases {
        param ( $command, $arguments, $Expected, $OutVariable )
        & $command -OutVariable $OutVariable > $null
        Get-Variable -ValueOnly $outVariable | should be $Expected
    }

}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


In reply to: 77278055 [](ancestors = 77278055)

@bingbing8

Copy link
Copy Markdown
Contributor Author

��D�e�s�c�r�i�b�e� �"�T�e�s�t�s� �f�o�r� �h�a�s�h�t�a�b�l�e� �t�o� �P�S�C�u�s�t�o�m�O�b�j�e�c�t� �c�o�n�v�e�r�s�i�o�n�"� �-�T�a�g�s� �"�C�I�"� �{�

fixed


In reply to: 244248919 [](ancestors = 244248919)


Refers to: test/powershell/Language/Scripting/HashtableToPSCustomObjectConversion.Tests.ps1:1 in 31f22c6. [](commit_id = 31f22c6, deletion_comment = False)

@bingbing8

Copy link
Copy Markdown
Contributor Author

� � � � � � � � �I�t� �'�$�a� �t�y�p�e�'� �{� �$�a� �-�i�s� �[�S�y�s�t�e�m�.�M�a�n�a�g�e�m�e�n�t�.�A�u�t�o�m�a�t�i�o�n�.�P�S�O�b�j�e�c�t�]� �|� �S�h�o�u�l�d� �B�e� �$�t�r�u�e� �}� � � � � � � � �

fixed


In reply to: 244249354 [](ancestors = 244249354)


Refers to: test/powershell/Language/Scripting/HashtableToPSCustomObjectConversion.Tests.ps1:15 in 31f22c6. [](commit_id = 31f22c6, deletion_comment = False)

@bingbing8

Copy link
Copy Markdown
Contributor Author

fixed


In reply to: 244251597 [](ancestors = 244251597)


Refers to: test/powershell/Language/Scripting/HashtableToPSCustomObjectConversion.Tests.ps1:66 in 31f22c6. [](commit_id = 31f22c6, deletion_comment = False)

@bingbing8

Copy link
Copy Markdown
Contributor Author

@JamesWTruher I updated the tests based on your feedback. some of the replies don't show in browser. please check out. Thanks!

@vors

vors commented Sep 8, 2016

Copy link
Copy Markdown
Collaborator

Assigning the PR to @JamesWTruher


It '$a should not be $null' { $script:a | Should Not Be $null }
It '$a type' { $script:a | should BeOfType "System.Management.automation.psobject" }
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that this is much too complicated, can't it just be:

It 'New-Object cmdlet should accept empty hashtable or $null as Property argument' {
      $a = new-object psobject -property
      $a | should not BeNullOrEmpty
      $a | should BeOfType "System.Management.Automation.PSObject"
}

I don't see the point of the extra it statements, if the first line throws the test will fail

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.


In reply to: 78253881 [](ancestors = 78253881)

@JamesWTruher

JamesWTruher commented Sep 9, 2016

Copy link
Copy Markdown
Collaborator

:shipit:

@bingbing8

Copy link
Copy Markdown
Contributor Author

@JamesWTruher Thanks for your feedback. I addressed all of them. Please check.

@JamesWTruher

Copy link
Copy Markdown
Collaborator

:shipit:

Comment thread test/csharp/csharp.nuget.props Outdated
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, remove this file from the PR.
In #2182 @douglaswth added it to ,gitignore.

Particularly because this file contains env-specific line

<NuGetPackageRoot>C:\git\part4\Packages</NuGetPackageRoot>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergei Vorobev good catch. I removed the file. Thanks!


In reply to: 78430315 [](ancestors = 78430315)

@vors vors assigned vors and unassigned JamesWTruher Sep 12, 2016
@vors

vors commented Sep 12, 2016

Copy link
Copy Markdown
Collaborator

🕐

@vors vors merged commit fd4552b into PowerShell:master Sep 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.