Closed cesarfp closed 6 years ago
$ClassName$ refers to the name of the class being tested, and is not valid in the mock field initialization format string. See https://github.com/Microsoft/UnitTestBoilerplateGenerator/wiki/Custom-Format-Tokens
It sounds like you'd like the ClassName token to be available here as well. Would you be able to work around it by naming the field _testedClass or something static?
Hi! Thanks for your reply. Yes, that's what I was trying to do. I need the ClassName token because this is the way that I initialize the mock fields. Something static doesn't help me because I was trying to create the template for be able to generate the unit tests of my other classes, but it looks like this is not possible then :/
I can't say I fully understand what you're going for, but it might be pretty easy to allow the "global" tokens at this scope as well.
How can I do that? Inside the code?
Oh sorry, I'm just talking about how hard it would be for me to do. The change is on my backlog, I'll work on it when I find some time.
What a pity. I think that would be a good feature because it is less restricted and more customizable. Thanks for your help!
You misunderstand. I said I'd implement it. :P
I just said that because I wanted to use the extension in my current project. But It's great to hear you have the change on your backlog. Thanks.
If it's any consolation it's the only item on the backlog. :)
Haha, thanks man, I'll be happy to wait for the update!
Just released 1.6.9. It will replace globally-scoped tokens in the interface templates.
In "Mock field initialization format" field I have this:
$InterfaceMockName.CamelCase$ = $ClassName.CamelCase$.Get<$InterfaceType$>();
And the result is this:
countryRepository = $ClassName$.Get();