How to recognize that mapping ViewModel to Model was break?

Topics: Issues / bugs
Feb 22, 2012 at 4:43 PM

Hi Geert,

Thanks for great MVVM framework.

We are developing WPF Front-End using Catel, our partners are developing Back-End containing Models. Models are POCO - without inheritance DataObjectBase. Our ViewModels inherit ViewModelBase.

In development process our partners are changing DB sometimes and also Models classes. This is strong stability issue, because we don’t know in VS(Visual Studio) build process that changes were made in Models, only in run-time (when run app. and use ViewModel) app throw exceptions.

Is it possible recognize that our mapping ViewModel to Model was break in VS build process or in some unit tests or somehow else?

Thanks’ for reply.

Feb 22, 2012 at 5:09 PM

Hi Kurko,

The only way to be really sure is to write unit tests. Then inject the model and you will get an exception when a mapping is invalid.

 

Best regards,

Geert

Oct 8, 2012 at 4:23 PM

Hi Geert,

I'd like to re-open this topic. I am experiencing problems validating consistency of ViewModelToModel mappings against the Model properties. I have written unit tests for each model used. Each test is simple, the only step is construction of the Model object that causes mappings initialization. These tests work fine except one situation.

If my Model class contains nullable property {e.g. int?} mapped in viewModel using the ViewmodelToModel attribute and I change the propertz in model class to non/nullable (int), my unit test isn't able to catch this change. It means, no exception is raised at the Model object construction time. Do you have any idea how to fix this issue? I would really appreciate any kind of suggestion to make this work as expected.

Thanks.

Tomas

Oct 8, 2012 at 6:48 PM

Can you provide the unit test that fails? And... did you try the latest beta via nuget?