Change NUnit Assertion behaviour

himanshu.dwivedi's Avatar

himanshu.dwivedi

14 Jun, 2018 07:34 PM

How can I change my Assert statement behaviour from:

Assert.That(User.HasOrderInvoice, Is.True)
to
Assert.That(User.HasOrderInvoice, Is.True, "Assert.That(User.HasOrderInvoice, Is.True)")

I don't see a way to do this on PostSharp.

  1. Support Staff 1 Posted by PostSharp Techn... on 15 Jun, 2018 09:21 AM

    PostSharp Technologies's Avatar

    Hello,

    is your goal to preserve the code exactly? If so, it's probably better to do this with Roslyn as you would have access to the actual code.

    PostSharp currently doesn't have supported (documented) way to alter code on call site level. Most of aspects actually change either type or method declarations, not the site these are used on.

    Best regards,
    Daniel

  2. 2 Posted by himanshu.dwived... on 18 Jun, 2018 11:25 PM

    himanshu.dwivedi's Avatar

    If that's not possible then at least there should be a way to change the behaviour by intercepting the call?

  3. Support Staff 3 Posted by PostSharp Techn... on 19 Jun, 2018 01:17 PM

    PostSharp Technologies's Avatar

    Hi,

    using PostSharp's method interception you don't get access to the original code, just to the methods signatures and values of method call parameters. So as Daniel recommended, you'd need Roslyn (or another tool) to obtain the source code of the method call.

    Best regards,
    -tony

  4. Support Staff 4 Posted by PostSharp Techn... on 27 Jun, 2018 04:35 PM

    PostSharp Technologies's Avatar

    Hello,

    We are going to close this request as we believe it was solved. Please feel free to reopen the discussion if you need more help.

    Best regards,
    PostSharp Team

  5. PostSharp Technologies closed this discussion on 27 Jun, 2018 04:35 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac