Mocked Object Properties

Welcome Forums Pester Mocked Object Properties

Viewing 1 reply thread
  • Author
    Posts
    • #68262
      Participant
      Topics: 1
      Replies: 15
      Points: 0
      Rank: Member

      Hello Everyone,

      Currently when using New-MockObject we get an empty object with no properties set. It seems these properties are read only and aren’t able to be set without overriding the entire property with a note property of the same name. Is this the preferred method for populating the mock object, or is there another way to set these properties that I may be missing?

      For reference here is my current code to override the properties:

    • #68266
      Participant
      Topics: 28
      Replies: 140
      Points: 59
      Rank: Member

      Yes. That currently is the only way to populate the properties. I’ve intended to add that functionality to the New-MockObject function for awhile now but just haven’t got to it it. I want to do something like this:

      New-MockObject -Type ‘FOO’ -Property @{Name=’bar’;Type = ‘Property’; Value=’foo’},@{Name = ‘method1’;Type = ‘Method’; Value = ‘x’}

      • #68272
        Participant
        Topics: 1
        Replies: 15
        Points: 0
        Rank: Member

        Thanks for the quick reply, Adam.

Viewing 1 reply thread
  • The topic ‘Mocked Object Properties’ is closed to new replies.