Skip to content

Commit 0105a95

Browse files
committed
Add test from issue to regression test suite
1 parent acbbe61 commit 0105a95

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

tests/Moq.Tests/Regressions/IssueReportsFixture.cs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2467,7 +2467,43 @@ public void InvokeApplyRule(object obj)
24672467
}
24682468

24692469
#endregion
2470-
2470+
2471+
#region 809
2472+
2473+
public class Issue809
2474+
{
2475+
[Fact]
2476+
public void Can_use_mocked_object_of_type_with_ctor_args_as_argument_in_setup_expression()
2477+
{
2478+
var mock1 = new Mock<IProperty>();
2479+
var mock2 = new Mock<IMethod>();
2480+
var ndc = new ClassWithoutDefaultConstructor(string.Empty);
2481+
2482+
mock1.Setup(x => x.Value).Returns(ndc);
2483+
var mockedObject1 = mock1.Object;
2484+
mock2.Setup(x => x.Test(mockedObject1.Value));
2485+
}
2486+
2487+
public class ClassWithoutDefaultConstructor
2488+
{
2489+
public ClassWithoutDefaultConstructor(string dummy)
2490+
{
2491+
}
2492+
}
2493+
2494+
public interface IProperty
2495+
{
2496+
ClassWithoutDefaultConstructor Value { get; }
2497+
}
2498+
2499+
public interface IMethod
2500+
{
2501+
void Test(ClassWithoutDefaultConstructor value);
2502+
}
2503+
}
2504+
2505+
#endregion
2506+
24712507
#region #810
24722508

24732509
public class _810

0 commit comments

Comments
 (0)