Skip to content

Assertion passes when an argument is used from the substitute itself #749

Open
@Epicycle23

Description

@Epicycle23

Describe the bug
When passing a parameter from the substitute itself to a (received) assertion it passes although it clearly shouldn't.

To Reproduce

        public interface ICandidate
        {
            string Name { get; set; }
            void Perform(string input, IEnumerable<string> values);
        }
        [TestMethod]
        public void Substitute_Received_ShouldNotPass()
        {
            var candidate = Substitute.For<ICandidate>();
            candidate.Perform(candidate.Name, new[] { "a" });
            candidate.Received(1).Perform(candidate.Name, Arg.Is<IEnumerable<string>>(new[] { "b" }));
        }

Expected behaviour
The example test should not pass due to the not matching second argument.

Environment:

  • NSubstitute version: 5.1.0.0
  • NSubstitute.Analyzers version: CSharp 1.0.16
  • Platform: .net framework 4.8 on windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugReported problem with NSubstitute behaviour

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions