title: How do I correctly mock my Function to return a custom property with Pester?
body: <p>I'm a bit new to PowerShell and specifically Pester testing. I can't seem to recreate a scenario for the function I am making Pester test. </p>
  
  <p><strong>Here is the code:</strong></p>
  
  <pre><code>    $State = Get-Status
  
      if(State) {
      switch ($State.Progress) {
      0 {
         Write-Host "Session for $Name not initiated. Retrying."
        }
  
      100{
       Write-Host "Session for $Name at $($State.Progress) percent"
        }
  
      default {
       Write-Host "Session for $Name in progress (at $($State.Progress) 
      percent)."
         }
      }
  </code></pre>
  
  <p>I've mocked <code>Get-Status</code> to return true so that the code path would go inside the <code>if</code> block, but then the result doesn't have any value for <code>$State.Progress</code>. </p>
  
  <p>My test would always go into the default block in terms of code path. I tried
  creating a custom object <code>$State = [PSCustomObject]@{Progress = 0}</code> to no avail.</p>
  
  <p><strong>Here is part of my Pester test:</strong></p>
  
  <pre><code>    Context 'State Progress returns 0' {
      mock Get-Status {return $true} -Verifiable
      $State = [PSCustomObject]@{Progress = 0}
      $result =  Confirm-Session 
         it 'should be' {
             $result | should be "Session for $Name not initiated. Retrying."
          }
      }
  </code></pre>