Add tests for substituted properties that used as argument matchers#367
Add tests for substituted properties that used as argument matchers#367dtchepak merged 4 commits intonsubstitute:masterfrom
Conversation
|
Following questions, should these tests fail: [Test]
public void Return_result_for_property_argument()
{
_something.SomeProperty = 2;
Arg.Any<int>()
_something.Echo(_something.SomeProperty);
Assert.That(_something.Echo(1), Is.EqualTo(""), "First return");
Assert.That(_something.Echo(2), Is.EqualTo("two"), "Second return");
}
[Test]
public void Return_result_for_property_argument()
{
_something.SomeProperty = 2;
Arg.Any<int>()
// same but with Returns
_something.Echo(_something.SomeProperty).Returns("two");
Assert.That(_something.Echo(1), Is.EqualTo(""), "First return");
Assert.That(_something.Echo(2), Is.EqualTo("two"), "Second return");
} |
|
Well, I'd say that both the scenarios should fail on the |
|
Yes, I would expect that. But now it fails for |
|
Ok, probably we should align, because I see a bit different results. Now about the reason of the CI failure. The following test failed: [Test]
public void Should_fail_with_redundant_exception_if_more_specifications_than_arguments_scenario_4()
{
// This spec will be ignored, however it's good to let user know that test might not work how he expects.
Arg.Is(42);
var ex = Assert.Throws<RedundantArgumentMatcherException>(() =>
{
_something.Echo(_something.SomeProperty);
});
Assert.That(ex.Message, Contains.Substring("42"));
}The scenario is a bit tricky. If you add
From NSubstitute perspective there is no way to handle this scenario (currently). Probably, we could find those ways, but it's a matter of a separate discussion. I'd suggest to transform this test and add |
|
@zvirja You are right! Thanks. I fixed the test to reflect the supported case. |
|
@alexandrnikitin LGTM |
|
Thanks everyone 😄👍 |
Adds tests for substituted properties used as argument matchers.