What I would do;
First, turn the settings into contracts;
public interface IApplicationSettings
{
ICommunicationSettings CommunicationSettings{get;}
IConfigurationSettings ConfigurationSettings{get;}
}
Now, break up your logic into separate concerns and pass in your settings at the highest level posible; Such that if MyLogicForSomething
only concerns itself with the communication settings, then only pass in the communication settings;
public class MyLogicForSomething
{
public MyLogicForSomething(ICommunicationSettings commSettings)
{
}
public void PerformSomething(){/* ... */}
}
ICommunicationSettings is easily mockable here; with something like Rhino Mocks
You can now easily test to ensure something in your settings is called/set when you run your logic
var commSettings = MockRepository.GenerateStub<ICommunicationSettings>();
var logic = new MyLogicForSomething(commSettings );
logic.PerformSomething()
commSettings.AssertWasCalled( x => x.SaveSetting(null), o=>o.IgnoreArguments() );