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

Can't scrub Moq snapshots #1414

Open
solidaum opened this issue Mar 4, 2025 · 0 comments
Open

Can't scrub Moq snapshots #1414

solidaum opened this issue Mar 4, 2025 · 0 comments

Comments

@solidaum
Copy link

solidaum commented Mar 4, 2025

Can't scrub Moq snapshots. Happy to fix it but at present I have no clue why its not scrubbing.

Repro

Reproduced

  • Verify: 28.12.0-28.13.0
  • NUnit: 4.3.2
  • XUnit: 1.1.0
  • Moq: 4.20.72
// NotEqual:
// - Received: Tests.CanScrubReplace.received.txt
//     Verified: Tests.CanScrubReplace.verified.txt
//
//     FileContent:
//
// NotEqual:
//
// Received: Tests.CanScrubReplace.received.txt
//     Verified: Tests.CanScrubReplace.verified.txt
//     Compare Result:
// [
// {
//     Method: ITarget.Method(int a, int b),
//     Arguments: [
//     1,
//     -       INT
//     +       2
//         ],
//     ReturnValue: response
// }
// ]
[Fact]
public Task CanScrubReplace()
{
    var mock = new Mock<ITarget>();

    mock.Setup(_ => _.Method(It.IsAny<int>(), It.IsAny<int>()))
        .Returns("response");

    var target = mock.Object;
    target.Method(1, 2);
    return Verify(mock).ScrubLinesWithReplace(
        x => x.Replace("2", "INT")
    );
}

// Works as expected
[Fact]
public Task CanScrubReplaceString()
{
    var mock = """
               [
                 {
                   Method: ITarget.Method(int a, int b),
                   Arguments: [
                     1,
                     2
                   ],
                   ReturnValue: response
                 }
               ]
               """;
    return Verify(mock).ScrubLinesWithReplace(
        x => x.Replace("2", "INT")
    );
}

PR

Repro Branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant