pose
pose copied to clipboard
Allow to isolate a parent property on a child instance
Version: Nuget Pose 1.2.0.
Trying to shim an instance property of a parent class on an instance of a derived class silently fails. Shimming the same property on an instance of the parent class works great.
Repro test:
class Sut
{
private string _text;
public string text { get => _text; set => _text = "unshimmed " + value; }
}
class ChildSut : Sut { }
[Fact]
public void PropertySetterShimWorksOnParent()
{
var sut = new ChildSut();
string capturedText = null;
var shimText = Shim.Replace(() => sut.text, true).With((ChildSut @this, string value) => { capturedText = value; });
PoseContext.Isolate(() =>
{
sut.text = "test";
}, shimText);
Assert.Null(sut.text);
Assert.Equal("test", capturedText);
}
Assert fails with Actual: unshimmed test
Try changing the ChildSut to Sut, I think I had the same issue with my own isolation attempt