Found a use case for a feature of the .NET mocking framework Moq that may not be that well known, and was new to me at least. I had a method under test that - via a number of overloaded extension methods - called an underlying method in the Umbraco CMS. The details aren't really important, but specifically it was the method GetImageUrl on IImageUrlGenerator that I was mocking to return a known output. I was then testing how my method used that result it in it's processing. I could see the method failing when I had a setup like this: But passed with this: So clearly we weren't passing in the Height parameter that I was expecting. One way to solve this would be to get the Umbraco code locally and step into it, but I found another way that I read about on this closed issue for the Moq library. It provides a means of capturing the parameters passed to a mocked method, and then establishing what they are via a breakpoint or logging. That revealed that so...
Head of CMS at Umbraco. Previously with digital agency Zone, building solutions on .NET and using Umbraco, EPiServer and Sitecore CMS. This blog is used as a repository for various tips, tricks, issues and impressions drawn from the use of technology in my work and interests. All words are my own.