Naming custom assertions - help/guidance appreciated

27 views
Skip to first unread message

Stuart Leeks

unread,
Oct 28, 2015, 1:47:11 AM10/28/15
to Pester
I created a custom assertion method for testing whether arrays match and just buried it inside the project that I created it for: https://github.com/stuartleeks/posh-dnvm/blob/master/PesterMatchArray.ps1. (For expected behaviour, see the tests: https://github.com/stuartleeks/posh-dnvm/blob/master/PesterMatchArray.Tests.ps1)

I'm now using it in another project, so figure that it's probably worth taking the time to pull it out and make it a separate project. Before I do that, I want to ensure that I have a sensible name for the assertion, so any feedback/guidance would be greatly appreciated :-)

The assertion is MatchArray, and it performs an order-insensitive comparison (i.e. @(1,2) matches @(2,1)). Does MatchArray convey that semantic? Or should it be something more like MatchArrayUnordered? 

And would it be useful to have another assertion that performs an order-sensitive assertion if I publish this?

Thanks in advance,
Stuart

Matt Wrock

unread,
Oct 28, 2015, 4:45:22 PM10/28/15
to Stuart Leeks, Pester

You might call it MatchValues and use Compare-Object instead of –contains which will likely simplify your implementation.

 

If you wanted to assert order, you might go with MatchValuesExactly which seems to be consistent with the current convention but I’m not convinced its very clear.

--
You received this message because you are subscribed to the Google Groups "Pester" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pester+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

 

Reply all
Reply to author
Forward
0 new messages