Skip to content

Conversation

@bingbing8
Copy link
Contributor

Added tests for hashtabletoPSCustomObjectConversion, OutErrorVairable. Please review.

@msftclas
Copy link

msftclas commented Sep 1, 2016

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
Copy link

msftclas commented Sep 2, 2016

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
Copy link
Collaborator

JamesWTruher commented Sep 2, 2016

��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
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
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
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
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
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
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
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
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
Copy link
Collaborator

vors commented Sep 8, 2016

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
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
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
Copy link
Collaborator

JamesWTruher commented Sep 9, 2016

:shipit:

@bingbing8
Copy link
Contributor Author

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

@JamesWTruher
Copy link
Collaborator

:shipit:

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
Copy link
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
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
Copy link
Collaborator

vors commented Sep 12, 2016

🕐

@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