You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class Issue56_NestedPropertyCalls
{
public interface IFoo
{
string StringProperty { get; set; }
}
[Test]
public void Nested_calls_to_properties()
{
const string expectedResult = "asldkfjdlkfj dslkfj";
var sub0 = Substitute.For<IFoo>();
var sub1 = Substitute.For<IFoo>();
sub1.StringProperty = expectedResult;
sub0.StringProperty.Returns(sub1.StringProperty);
//FAILS: Is equal to ""
//This is because Returns(..) can't tell it is meant to apply to sub0. Applies to last call (sub1) instead.
Assert.That(sub0.StringProperty, Is.EqualTo(expectedResult));
}
[Test]
public void Non_nested_calls()
{
const string expectedResult = "asldkfjdlkfj dslkfj";
var sub0 = Substitute.For<IFoo>();
var sub1 = Substitute.For<IFoo>();
sub1.StringProperty = expectedResult;
var prop = sub1.StringProperty;
sub0.StringProperty.Returns(prop);
//PASSES
Assert.That(sub0.StringProperty, Is.EqualTo(expectedResult));
}
}
The text was updated successfully, but these errors were encountered:
I think that issue can be fixed by restoring previous values for last call router / last call at the end of ReturnConfiguredResultHandler.Handle execution
The text was updated successfully, but these errors were encountered: