Skip to content

Document protected member support #417

@vbreuss

Description

@vbreuss

Description

Mockolate supports setting up and verifying protected members, but this is completely undocumented.

Missing Documentation

  • SetupMock.Protected.Method() and .Property()
  • VerifyMock.Protected.Invoked(), .Got(), .Set()
  • Examples of working with protected methods and properties

Suggested Documentation

Add a new section titled "Working with Protected Members":

### Working with Protected Members

Mockolate allows you to setup and verify protected methods and properties:

```csharp
var sut = Mock.Create<MyChocolateDispenser>();

// Setup protected method
sut.SetupMock.Protected.Method(\"DispenseInternal\",
    It.Is(\"Dark\"), It.IsAny<int>())
    .Returns(true);

// Setup protected property
sut.SetupMock.Protected.Property(\"InternalStock\").InitializeWith(100);

// Verify protected method was called
sut.VerifyMock.Protected.Invoked(\"DispenseInternal\",
    It.Is(\"Dark\"), It.IsAny<int>()).Once();

// Verify protected property was accessed
sut.VerifyMock.Protected.Got(\"InternalStock\").AtLeastOnce();

Metadata

Metadata

Labels

documentationImprovements or additions to documentationstate: releasedThe issue is released

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions