I have a web page that shows different messages according to different conditions.
I want to unit test this so I configured my project to use MVVM and I’m testing my ViewModel.
My ViewModel now format different messages. How can I test this? I don’t want to reproduce all strings, it seems dirty…
Now I’m doing this:
void test()
{
string message = _viewModel.DoWork();
Assert.AreEqual(message, Resource.MyResourceText);
}
But this is a simple case. Now I have dynamic strings containing system date and other variables.
How can I test this in an elegant way? Thanks!
I resolved in this way:
In this way I can check that my message “hi ric” must conform to “hi {0}”