How can I assert that a variable satisfies any one of two values in Visual Studio’s unit testing environment?
I’ve seen other testing frameworks do it like this:
Assert.That(result.ViewName, Is.EqualTo("HomePage") | Is.Empty);
I’m not experienced with Visual Studio’s unit testing environment.
First of all, I think the sample line of code you typed contains an error, if you have no intention to perform a bitwise OR.
Secondly, I suspect a misleading test here, since unit testing shall tests for one and only one specific scenario. So, if you assigned, for example, one value to a property, you expect this very value to be returned by its getter.
Third, here’s how I would go for it, considering I might miss your point and you definitely need to test for either result.
On the other hand, I have never ever tested a scenario where I expected two different results from the same unit test.
Assert.Thatmight be good as well.