Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automoq breaks Matching.ParameterName #1134

Open
cocogorilla opened this issue Jul 25, 2019 · 0 comments
Open

automoq breaks Matching.ParameterName #1134

cocogorilla opened this issue Jul 25, 2019 · 0 comments
Labels
bug Moq An issue related to Moq triage Something that's being investigated xUnit Any issues related to xUnit

Comments

@cocogorilla
Copy link
Contributor

cocogorilla commented Jul 25, 2019

When using AutoMoq integration and matching by ParameterName, the match breaks.

`

    public interface ITestOp { }

    public class TestOp
    {
        private readonly ITestOp _instanceOne;
        private readonly ITestOp _instanceTwo;

        public TestOp(ITestOp instanceOne, ITestOp instanceTwo)
        {
            _instanceOne = instanceOne;
            _instanceTwo = instanceTwo;
        }
        public ITestOp InstanceOne => _instanceOne;
        public ITestOp InstanceTwo => _instanceTwo;
    }

    [Theory, Gen]
    public void WorksWithoutMoqs(
        [Frozen(Matching.ParameterName)] ITestOp instanceOne,
        [Frozen(Matching.ParameterName)] ITestOp instanceTwo,
        TestOp sut)
    {
        Assert.Equal(instanceOne, sut.InstanceOne);
        Assert.Equal(instanceTwo, sut.InstanceTwo);
    }

    [Theory, Gen]
    public void FailsWithMoqs(
        [Frozen(Matching.ParameterName)] Mock<ITestOp> instanceOne,
        [Frozen(Matching.ParameterName)] Mock<ITestOp> instanceTwo,
        TestOp sut)
    {
        Assert.Equal(instanceOne.Object, sut.InstanceOne);
        Assert.Equal(instanceTwo.Object, sut.InstanceTwo);
    }

`

@aivascu aivascu added bug triage Something that's being investigated xUnit Any issues related to xUnit Moq An issue related to Moq labels Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Moq An issue related to Moq triage Something that's being investigated xUnit Any issues related to xUnit
Projects
None yet
Development

No branches or pull requests

2 participants