How to unit test configs

We work with very large configuration files that contain many Unity and WCF settings.

When we open some of these configurations in the SVC configuration editor, or even try to open a web application using these configurations, we get errors showing any typos or errors. For instance. WCF binding is invalid or does not exist, etc., or the configuration section does not exist, two end tags, etc.

Is there a way to β€œconfirm” the configuration via unit test? So there is one more thing that may go wrong when an application moves to a new environment.

+4
source share
1 answer

You can write a set of functions that will work with XML. It is fairly easy to find out if all sections in a file are declared if specific binding parameters are specified. If the file cannot be loaded, this means that all XML is invalid. You can use SelectSingleNode and SelectNodes with XPath expressions.

+1
source

Source: https://habr.com/ru/post/1303901/


All Articles