Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Tests/Mockolate.Tests/MockTests.WrappingClassTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ public sealed partial class MockTests
{
public sealed class WrappingClassTests
{
[Fact]
public async Task Wrap_ClassWithoutParameterlessConstructor_ShouldDelegateToWrappedInstance()
{
ServiceWithConstructor myService = new("real");
ServiceWithConstructor wrappedService = ServiceWithConstructor.CreateMock("mock").Wrapping(myService);

string result = wrappedService.Format("value");

await That(result).IsEqualTo("real:value");
await That(wrappedService.Mock.Verify.Format("value")).Once();
}

[Fact]
public async Task Wrap_Events_ForwardEventsFromWrappedInstance()
{
Expand Down Expand Up @@ -145,6 +157,19 @@ public async Task Wrapping_ShouldIgnoreProtectedMembers()
await That(myMock.Mock.Verify.MyPublicMethod()).Once();
}

internal class ServiceWithConstructor
{
private readonly string _prefix;

public ServiceWithConstructor(string prefix)
{
_prefix = prefix;
}

public virtual string Format(string value)
=> $"{_prefix}:{value}";
}

internal class ServiceWithProtectedMembers
{
public virtual int MyPropertyWithProtectedSetter { get; protected set; } = 10;
Expand Down
Loading