1

Set-PropertyValueSharePoint リスト アイテムのプロパティ値を設定するPowerShell コマンド ( ) をテストしようとしています。Invoke-WebMethod関数は実際の作業に関数 do を使用します。

私の現在のSet-PropertyValue.Test.ps1ファイル:

# include stuff omitted

Describe 'Set-PropertyValue' {

  #
  # arrange
  #

  # set $url, $list, $id, $property variables
  ...

  # the value that it should be 
  $expected=10.5

  BeforeEach {
    # get the property's current value
    $original = Get-PropertyValue $url $list $id $property
  }

  AfterEach {
    # restore original value
    Set-PropertyValue $url $list $id $property $original
  }

  It "Should set a property's value" {

    #
    # act
    #

    # update property's value
    $response = Set-PropertyValue $url $list $id $property $expected

    # get the new value
    $actual = Get-PropertyValue $url $list $id $property

    #
    # assert
    #

    $response.statuscode | should be 204 # no content
    $actual | Should Be $expected

  } # It

} # Describe

私はいくつかの理由でこれが好きではありません:

  • 外部依存Get-PropertyValue
  • テスト分離なし。SharePoint リストに変更が加えられた
  • リスト項目を望ましくない状態に平準化する可能性
  • おそらくループで、複数のプロパティを簡単にテストするように構造化されていないテスト

これをテストするより良い方法はありますか?

4

1 に答える 1